Note that there are some explanatory texts on larger screens.

plurals
  1. PORead records from one table , and write to another table. Exception occurs procedure or function has too many arguments specified?
    primarykey
    data
    text
    <p>I am trying to retrieve list of records from one table , and write to another table. I've used a simple query to retrieve the values to SqlDataReader,then load them to a DataTable. Using the DataTableReader , I am going through the entire data set which is Saved in DataTable. The problem is, while reading each and every record I am trying to insert those values to another table using a Stored Procedure.But it only insert the first row of values,and for the second row onward giving some Exception saying.<em>"procedure or function has too many arguments specified"</em>.</p> <hr> <pre><code>string ConStr = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString; SqlConnection NewCon = new SqlConnection(ConStr); NewCon.Open(); SqlCommand NewCmd3 = NewCon.CreateCommand(); NewCmd3.CommandType = CommandType.Text; NewCmd3.CommandText ="select * from dbo.Request_List where group_no ='" +group_no+ "'"; NewCon.Close(); NewCon.Open(); SqlDataReader dr = (SqlDataReader)NewCmd3.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); DataTableReader reader = new DataTableReader(dt); NewCmd.Dispose(); NewCon.Close(); NewCon.Open(); SqlCommand NewCmdGrpReqSer = NewCon.CreateCommand(); NewCmdGrpReqSer.CommandType = CommandType.StoredProcedure; NewCmdGrpReqSer.CommandText = "Voucher_Request_Connection"; if (reader.HasRows) { int request_no = 0; while (reader.Read()) { request_no = (int)reader["request_no"]; NewCmdGrpReqSer.Parameters.Add("@serial_no", serial_no); NewCmdGrpReqSer.Parameters.Add("@request_no", request_no); try { NewCmdGrpReqSer.ExecuteNonQuery(); MessageBox.Show("Connection Updated");//just to check the status.tempory } catch (Exception xcep) { MessageBox.Show(xcep.Message); } MessageBox.Show(request_no.ToString());// } NewCmdGrpReqSer.Dispose(); NewCon.Close(); } </code></pre> <p>Any Solutions ? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload