Results 1 to 4 of 4

Thread: Can we open Two SQL Command Object at a time

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    141

    Angry 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width