none
conversion failed when converting the varchar value 'id :' to data type int.' RRS feed

  • Question

  •  private void buytichet_Click_1(object sender, EventArgs e)
            {

                 SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=event_manegment;Integrated Security=True");
                 con.Open();
                 string query = "insert into event_user(Event_id) values('" + UserNameup.Text + "')";
                 SqlDataAdapter sda = new SqlDataAdapter(query, con);
                 sda.SelectCommand.ExecuteNonQuery();

                 cmd.Parameters.Add("@Event_id", textBox1.Text);

                 MessageBox.Show("db entered");


                 //cmd.Parameters.Add("@User_id", textBox2.Text);
                 con.Close();
            }
    Saturday, December 14, 2019 8:32 PM

All replies

  • You add parameters BEFORE you do ExecuteNonQuery. How else?

    - MyCatAlex

    Saturday, December 14, 2019 8:44 PM
  • Hi engyassem,

    1.In SSIS , we can use Data Conversion and Derived Column to change the datatypes of columns.

    2.If you want to use C# to change the datatypes, please try the following codes:

       table.Columns["country_code"].DataType = typeof(string);

       Please refer to Changing populated DataTable column data types.

    Best Regards,

    Mona


    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 16, 2019 2:57 AM
  • Hi,

    May I know if you have anything to update?

    Please remember to click "Mark as Answer" the responses that resolved your issue. 

    This can be beneficial to other community members reading this thread.

    Best Regards,

    Mona


    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

    Thursday, December 19, 2019 9:49 AM