R
Robert Bravery
HI all,
I'm trying my hand at async processing. I have the following, my question is
where do I close the sql connection. Do I close it in this function or in
the ExecCallback function, if so where, after the endexecutereader call?????
Thanks
Robert
string constr2 = ReadConFile("conString.txt".Trim()); //"Data
Source=ROBERT\\SQLExpress;Initial Catalog=Genport;Integrated Security=True;
Connection Timeout = 0;Asynchronous Processing=true";
constr2 += "; Connection Timeout = 0;Asynchronous Processing=true";
SqlConnection con2 = new SqlConnection(constr2);
SqlCommand cmd3 = new SqlCommand();
cmd3.Connection = con2;
cmd3.CommandType = CommandType.Text;
con2.Open();
toolStripStatusLabel1.Text = "Importing Data into table" + ", Please Wait...
";
this.Update();
cmd3.CommandText = cmdstr;
cmd3.CommandTimeout = 0;
AsyncCallback callback = new AsyncCallback(ExecCallback);
cmd3.BeginExecuteReader(callback, cmd3);
I'm trying my hand at async processing. I have the following, my question is
where do I close the sql connection. Do I close it in this function or in
the ExecCallback function, if so where, after the endexecutereader call?????
Thanks
Robert
string constr2 = ReadConFile("conString.txt".Trim()); //"Data
Source=ROBERT\\SQLExpress;Initial Catalog=Genport;Integrated Security=True;
Connection Timeout = 0;Asynchronous Processing=true";
constr2 += "; Connection Timeout = 0;Asynchronous Processing=true";
SqlConnection con2 = new SqlConnection(constr2);
SqlCommand cmd3 = new SqlCommand();
cmd3.Connection = con2;
cmd3.CommandType = CommandType.Text;
con2.Open();
toolStripStatusLabel1.Text = "Importing Data into table" + ", Please Wait...
";
this.Update();
cmd3.CommandText = cmdstr;
cmd3.CommandTimeout = 0;
AsyncCallback callback = new AsyncCallback(ExecCallback);
cmd3.BeginExecuteReader(callback, cmd3);