ADO.NET :: Efficient Way To Insert Couple Of Times?
Jan 18, 2011I would like to use insert statement to the same table with different values, lets say 5 times. What is the efficient way to do this?
View 2 RepliesI would like to use insert statement to the same table with different values, lets say 5 times. What is the efficient way to do this?
View 2 RepliesI have a simple asp.net web forms page that does an insert to my sql server db. My server was running slow at the time and I pressed Insert button several times because I didn't think it took but it did all 3 times.So I have duplicates from that one interaction. How would I prevent this?
View 2 RepliesI have a simple form that inserts a record into a SQL table.
The fields are:
SerialNum
TagNum
PONum
Location
Address
Description
This works great. However, I have now been asked to have the form insert x number of records at one time.
They want to be able to fill out the following fields:
PONum
Location
Address
Description
and then have texbox where they can add a number and have that number of the same record inserted.
I have DAL Layer, from where invoking a stored procedure to insert values into the table.
E.g.:-
[code]....
Now as requirement changed, per client request i have to add values 5 times. So what is the best practice?
Do i call this Stored Procedure 5 times from my DAL?
I have 2 table's
Table 1: Daily_item
Fields: Key_Guid Drescription Count
1 test 3
3 new item 2
I want to insert records form table 1 into table 2 but using the count field to duplicate the Key_guid record the new table.
New table example:
Table 2
Key_guid
1
1
1
3
3
I am building a search where I need to implement couple of features in it among others.
1- It should bring all synonyms, like if someone searches for couch, it should bring in matching results for that couch plus linguistic matches like (sofas, cushions etc). To accomplish that I am using Full Text Search. In my query I use FreeText but it does not yield the required results. That's what I do,
select * from Furn_Products Where FreeText(FurnName, 'Couch');
It should bring Names containing Cushions, Sofa and Couch off course but it only brings Names with Couch which I could also do by simple Like query. 2- I need to check for typos, like if someone types soofa, it should bring in results for sofa, couch etc.
I'm using VS 2008, .net 3.5 and C#. I'm using Ajax Modal popup to dispaly a panel that has HTML file upload control when user clicks on the update button in the gridview control. The prolems that I'm having:
1. After i click the upload button in the popup, everything is processed but then the popup would close itself. I would like it to stay there with the proper message displayed and only close when the user clicks on the cancel button.
2. When I click on the Upload File button, a Page_Load event is raised to the page, CtuMain.aspx.cs, but this is before the popup code upload the file. I would like to enable or dis-able my gridview's editWorkingDoc and btnUpdate buttons based on if the file upload is successful or not. I thought a Page_Load event to the CtuMain.aspx.cs is supposed to be raised when the popup closes but that is not happening. How can I fix this?
[Code...]
I have been learning ASP.NET my self and is about to dive into the nitty gritty by creating a club website for a club.
It will be basically pretty simple. It will have around 4-6 pages consisting of:
1. Homepage/News
2. Gallery
3. About
4. Contact
5. Calendar for events
My question is should I use MVC to develop such website? As I am totally a noob in MVC development, but if it is better then I would need to learn MVC first, otherwise I'll just do it the standard way.What should I use for the calendar of events?
For example i need create page to display few models. Inherits property can take in only one value, as i mean.
[Code]....
I want something like:
[Code]...
I was asked to build a couple of small and basic websites, without the use of database connections, just plain forms with information and a couple of images and forms. So my question is, if I only use those "html" controls of the toolbox, the performance of the site will increase against those with lots of .net controls?
Some one told me to use php or any script language to do that kind of stuff, but I only know to code in .net.
Basically, what I want to do is to get all my data in 1 statement and then pull data from that into a GridView. I already have the columns that I want displaying in the GridView, but now I want to insert a footer row in between the header row and all the datarows, that contains a couple columns that will be the same for every row in the GridView. So something along the lines of this:
Header1 Header2 Header3
Dept: Technology
data1 data2 data3
data4 data5 data6
data7 data8 data9
The thing is, I don't know what that "Dept" will be, so I want to pull it from my SqlDataSource that already has it.
I've got a c# handler that serves up audio files I've generated using text-to-speech. When the files are written to disk they sound fine, but when I try and play them in a browser (via the handler) using a quicktime plugin it cuts them short at about 2 seconds.
Inside the handler I'm using the following code...
context.Response.ClearContent();
context.Response.ClearHeaders();
context.Response.ContentType = "audio/x-wav";
context.Response.WriteFile(fileName);
context.Response.Flush();
I have set a couple of my DetailsView fields to readonly=true. In Update mode the fields are readonly but in Insert mode they are not readonly. What do I do to set it to readonly or blank (no field for entry)?
View 1 Repliesmy solution in VS 2008, consisting of a dozen projects, does not compile because it gives me errors on constructors of a couple of classes, telling me that lacks the constructor that takes one parameter, which lacks the parameterless constructor, and so on.Actually I have all the correct constructors, and other times I compile without problems.I'm not understand why I have these random problems, that it is practically impossible to replicate.
View 2 RepliesI have tried several ways but just cannot figure our how to populate some formviews with the data I have brought up in a gridview.
Here is my code so far. I just showing the code behind because my gridview and forms are not a problem. Where I am stuck is at the GridView1_SelectedIndexChanged at the bottom of the code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
[Code]....
This is my scenario. I have a couple of content place holders on a Master page which by default are empty.Two of the content place holders are laid out side by side. I'll call one MainContent and the other SidebarContent. What I'd like to see happen is if a child page has content in the SidebarContent, the width of the MainContent should be adjusted accordingly.Is there a way to determine at runtime from the Master page if the calling child page has populated the SidebarContent?How do I go about this, if possible?
View 1 RepliesI searched on this all morning, but I'm still not sure. If I create a session variable to pass some data between a couple of pages, does that variable time out after it reaches the timeout period set on IIS, or will it persist for the entire time the user keeps a session alive? For example, session variable is used shortly after login and then never again. Susy uses other pages for two hours and keeps session active. Did that first session variable die after 20 minutes, or is it still there 2 hours later?
View 4 RepliesIt's simple to do a webrequest, get the page and parse the html to get the title of the page. But I'm wondering if there is a more efficient way that is faster, and doesn't require downloading the whole html?
View 2 RepliesI am new to databases and linq, so my problem may be considered trivial. I currently start all my db requests in each class with:
DataClassesDataContext db = new DataClassesDataContext()
Then I proceed to make whatever linq request I need within the method and carry on with the main application logic.
Now, two interesting queries:
1) I believe I have seen people wrapping db usage within 'using'. Such as:
using (DataClassesDataContext db = new DataClassesDataContext())
{
...
}
If this is correct, then doesn't it mean that my class can't use a member 'db' variable anymore, but rather those db requests need to be made within each function call? Also, what exactly would happen if I don't use 'using' within the calls?
2) Running my app with SQL Profiler enabled, I see lots of connections opening and closing. Does this means that each
DataClassesDataContext call makes a separate connection? It seems inefficient, so is the right way to actually make the DataClassesDataContext object a static within each class being used?
What's the best way to do this? I have seen quite a few examples that use a Dataview etc. what is the best method. I'm thinking about speed issues when a grid has a few thousand records etc.
this is how I populate the gridview:
Code:
[code]....
I have a requirement where 15 listviews have to be loaded on a web page.But only one shown at a time. Number of columns will be only 2 for each and Number of rows for every listview is very limited.The thing I am not able to decide is the sorting method.1. If I am using the datasource control, it automatically sorts my listview.2. If I am programmatically populating listview , I will have to sort my datatable and rebind to the listview.To use the second method I have to store the datatables in sessions.So taking that into consideration, will datasource control be more efficient ?
View 4 RepliesAssuming a list of objects, each with an ID, what's the most efficient way of building a carousel, so that each object knows what its previous and next item is. The Last Item's previousId will link to the first item. The first item's previousId will link to the last.
I need the ID of the previous and the ID of the next, as this will be used to populate next and previous buttons on a web page.
I know I could iterate over them, adding placeholders for _next and _prev id, but what's the most efficient way to do this?
I figure my object should look like this:
class Item {
public int Id { get; set; }
public string ItemName { get; set; }
public int Next { get; set; }[code]....
I think I'm looking at this wrong way. Is there a better way of doing this?
I am making a blog application and for the sake of my question I have 2 tables: Posts & Comments. I would like to loop through the posts and use a nested loop to display the comments relating to a specific post. Currently, I am using this code:
[Code]....
Obviously this is a simplified version. Is this the most efficient method of displaying this kind of data?
I am outputting the entire HTML for my server control as follows:
public override void Render(HtmlTextWriter output)
{
output.Write(myStringBuilder.ToString());
}
myStringBuilder is a StringBuilder object that is manually built in a separate private method.Is this an efficient way to do it? Or is it better to pass the HtmlTextWriter to my private method and make multiple calls to HtmlTextWriter.Write()?
What is the most efficient way to transmit messages in WCF? I've done a few basic walkthroughs of WCF and upon analyzing the XML transmission I saw that they were very large by default... Containing what appears to me, as a lot of unnecessary information, for my needs. I'm looking for a way to send the shortest messages possible. How can I trim as much as possible from the XML? Can I remove all the header information. What approach for sending the shortest messages possible using XML in WCF?
View 3 Replies