none
Must declare the scalar variable "@ID". RRS feed

  • Question

  •  

    hai 

    hai,

    hai, I'm getting a problem in this code can any one suggest me plz..........?

    DataTable dst = new DataTable();
                string Query = "Insert into TNET_Overlay(ID,OverLay,KeyRow,Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12)VALUES(@ID,@Overlay,@KeyRow,@Col1,@Col2,@Col3,@Col4,@Col5,@Col6,@Col7,@Col8,@Col9,@Col10,@Col11,@Col12)";
               // string Query = " SELECT * from TNET_Overlay O LEFT OUTER JOIN TNET_Station S ON O.Overlay=S.ID";
                DataSet ds = Utility.SFISConnection.ExecuteDataSet(Query);
                SqlDataAdapter da = new SqlDataAdapter(Query, connection);
                da.Fill(ds);
                comboBox1.DisplayMember = "ID";
                comboBox1.ValueMember = "Location";
                ultraGridTT9.DataSource = ds;
                ultraGridTT9.DataBind();


    sateesh siriki

    • Moved by Barry Wang Thursday, July 19, 2012 5:39 AM Data related (From:.NET Framework Setup)
    Tuesday, July 17, 2012 3:37 PM

Answers

  • Is this your complete code for the INSERT command? Since you created parameters in your INSERT SQL statement, you also need to map those parameters to columns in your DataTable or to declare paramenets and provide values explicitly in your code.

    Val Mazur Microsoft MVP
    http://www.xporttools.net


    Friday, July 20, 2012 3:40 PM
    Moderator
  • In addition to what Val said about creating your parameters, you should be issuing a da.ExecuteNonQuery() rather than a da.Fill(ds), since you're trying to insert data, not fill the DataSet.

    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Saturday, July 21, 2012 4:00 PM

All replies