none
Must Declare a scalar value RRS feed

  • Question

  •  if (txt_kata_amount_check_search.Text != null)
                {
                    int id = Convert.ToInt32(txt_kata_amount_check_search.Text);
                    SqlDataAdapter adpter1 = new SqlDataAdapter("select sum(update_kata_amount)from Kata_Update_tbl where update_kata_amount_type='$' and customer_refernce=@id", con);
                    adpter1.SelectCommand.Parameters.AddWithValue("@customer_refernce", id);
                    DataTable datatbl1 = new DataTable();
                  //error it not pass the value of id  from data adapter to the data table ?
                    adpter1.Fill(datatbl1);
                    int Credits = Convert.ToInt32(datatbl1.Rows[0][0].ToString());
    Monday, December 23, 2019 5:20 AM

All replies

  • Hi oseedeqi,
    You can change 

    adpter1.SelectCommand.Parameters.AddWithValue("@customer_refernce", id);

    to

    adpter1.SelectCommand.Parameters.AddWithValue("@id",id);

    More details you can refer to this link.
    [SqlParameterCollection.AddWithValue(String, Object) Method]
    Best Regards, 
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 23, 2019 10:01 AM