Click here to Skip to main content
15,900,108 members
Home / Discussions / C#
   

C#

 
GeneralDataGrids and XML Pin
Skylo31-Mar-04 2:42
Skylo31-Mar-04 2:42 
GeneralRe: DataGrids and XML Pin
Charlie Williams31-Mar-04 4:09
Charlie Williams31-Mar-04 4:09 
GeneralPaste nodes Pin
bertcox31-Mar-04 1:53
bertcox31-Mar-04 1:53 
GeneralRe: Paste nodes Pin
partyganger31-Mar-04 4:44
partyganger31-Mar-04 4:44 
GeneralRe: Paste nodes Pin
partyganger31-Mar-04 4:44
partyganger31-Mar-04 4:44 
GeneralLoad Huge Data to SQL Server Pin
mhmoud rawas31-Mar-04 0:32
mhmoud rawas31-Mar-04 0:32 
GeneralRe: Load Huge Data to SQL Server Pin
Mazdak31-Mar-04 1:33
Mazdak31-Mar-04 1:33 
GeneralRe: Load Huge Data to SQL Server Pin
Heath Stewart31-Mar-04 4:54
protectorHeath Stewart31-Mar-04 4:54 
You parameterized queries for batch updates, like so (assumes insert only, such as for a data wharehouse):
// Setup connection and command.
SqlConnection conn = new SqlConnection("...");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO MyTable (Field1, Field2, Field3) " +
  "VALUES(@Field1, @Field2, @Field3)";
SqlParameter param1 = cmd.Parameters.Add("@Field1", SqlDbType.BitInt);
SqlParameter param2 = cmd.Parameters.Add("@Field2", SqlDbType.NVarChar, 40);
SqlParameter param3 = cmd.Parameters.Add("@Field3", SqlDbType.NVarChar, 40);
using (conn) // Closes the connection when done (even in error)
{
  conn.Open();
  while (true)
  {
    // Open CSV file, for example, then...
    string line = read next line from data file;
    // If no more lines, return false; otherwise, continue...
 
    string[] fields = line.Split(','); // Assumes CSV
    int id = Convert.ToInt32(fields[0]);
 
    param1.Value = id;
    param2.Value = fields[1];
    param2.Value = fields[2];
    cmd.ExecuteNonQuery();
  }
}
This should give you some idea of what to do. Also, don't use stored procs like Mazdak mentioned. There is a performance penalty when using simple statements like this.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Load Huge Data to SQL Server Pin
mhmoud rawas31-Mar-04 9:36
mhmoud rawas31-Mar-04 9:36 
GeneralRe: Load Huge Data to SQL Server Pin
Heath Stewart31-Mar-04 9:39
protectorHeath Stewart31-Mar-04 9:39 
GeneralRe: Load Huge Data to SQL Server Pin
ian mariano31-Mar-04 6:35
ian mariano31-Mar-04 6:35 
GeneralRe: Load Huge Data to SQL Server Pin
Jesse Squire1-Apr-04 7:23
Jesse Squire1-Apr-04 7:23 
GeneralRe: Load Huge Data to SQL Server Pin
mhmoud rawas2-Apr-04 4:26
mhmoud rawas2-Apr-04 4:26 
GeneralTextBox control Pin
Andy H31-Mar-04 0:27
Andy H31-Mar-04 0:27 
GeneralRe: TextBox control Pin
leppie31-Mar-04 6:19
leppie31-Mar-04 6:19 
GeneralClose resource Open by a web cam Pin
Daminda30-Mar-04 22:34
Daminda30-Mar-04 22:34 
GeneralRe: Close resource Open by a web cam Pin
Dave Kreskowiak31-Mar-04 3:26
mveDave Kreskowiak31-Mar-04 3:26 
GeneralAttributes Pin
Appelz30-Mar-04 20:36
Appelz30-Mar-04 20:36 
GeneralRe: Attributes Pin
Mazdak30-Mar-04 20:46
Mazdak30-Mar-04 20:46 
GeneralRe: Attributes Pin
partyganger30-Mar-04 22:39
partyganger30-Mar-04 22:39 
GeneralDetermining Active Custom Multiple Component Component Pin
Tristan Rhodes30-Mar-04 20:35
Tristan Rhodes30-Mar-04 20:35 
GeneralRe: Determining Active Custom Multiple Component Component Pin
Heath Stewart31-Mar-04 4:14
protectorHeath Stewart31-Mar-04 4:14 
GeneralOpaque Controls Showing Controls Underneath Pin
Tristan Rhodes30-Mar-04 20:31
Tristan Rhodes30-Mar-04 20:31 
GeneralRe: Opaque Controls Showing Controls Underneath Pin
Heath Stewart31-Mar-04 3:56
protectorHeath Stewart31-Mar-04 3:56 
GeneralRe: Opaque Controls Showing Controls Underneath Pin
Jesse Squire1-Apr-04 7:39
Jesse Squire1-Apr-04 7:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.