|
-
May 21st, 2005, 12:16 AM
#1
Thread Starter
Addicted Member
Can we open Two SQL Command Object at a time
Can we open Two SQL Command or SQL DataReader Object at a time
SqlCommand cmSQL = new SqlCommand("select * from PD_ComMachines",G1.cn);
SQLDR = cmSQL.ExecuteReader();
while (SQLDR.Read())
{
FillGrid(int.Parse(SQLDR["MachineNo"].ToString()));
}
internal void FillGrid(int MachineNO)
{
try
{
SqlCommand cmdFill = new SqlCommand ("ComberMachine",G1.cn);
cmdFill.CommandType=CommandType.StoredProcedure;
cmdFill.Parameters.Add("@machNo", SqlDbType.Int);
cmdFill.Parameters["@machNo"].Value = MachineNO;
cmdFill.Parameters["@machNo"].Direction = ParameterDirection.Input;
cmdFill.Parameters.Add("@Name", SqlDbType.VarChar,20);
cmdFill.Parameters["@CODateo"].Direction = ParameterDirection.Output;
cmdFill.ExecuteNonQuery();
System Generate Error :There is already an Open DataReader Assciateed with this connection which must be closed
// Retrive result from stored procedure
Name = (string)cmdFill.Parameters["@Name"].ToString();
TextBox1.Text = Name
Last edited by Waseemalisyed; May 21st, 2005 at 01:03 AM.
Reason: enhance
-
May 21st, 2005, 02:36 AM
#2
Re: Can we open Two SQL Command Object at a time
Read the MachineNo's Into an array... Close the DataReader Then Loop Thru the Machine Numbers Executing your SP.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
May 21st, 2005, 03:10 AM
#3
Thread Starter
Addicted Member
Re: Can we open Two SQL Command Object at a time
can we count record in dataReader
with out loop
-
May 21st, 2005, 12:42 PM
#4
PowerPoster
Re: Can we open Two SQL Command Object at a time
Try creating two different sql connections if you absolutely must have two readers open at the same time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|