SqlCommand INSERT INTO query does not execute

前端 未结 3 652
旧时难觅i
旧时难觅i 2020-12-07 05:55

Hello guys I have got this code:

SqlCommand scom = new SqlCommand(
                                \"INSERT INTO klient(name,surname) 
                               


        
相关标签:
3条回答
  • 2020-12-07 06:35

    You haven't executed the command.

    prikaz.ExecuteNonQuery();
    
    0 讨论(0)
  • 2020-12-07 06:39

    Missing the ExecuteNonQuery call

    SqlCommand prikaz = new SqlCommand("INSERT INTO klient(name,surname) values(@kname,@ksurname)", spojeni);
    
    prikaz.Parameters.AddWithValue("@kname", kname.Text);
    prikaz.Parameters.AddWithValue("@ksurname", ksurname.Text);
    spojeni.Open();
    prikaz.ExecuteNonQuery();
    ......
    

    A command should be executed to update the database...

    0 讨论(0)
  • 2020-12-07 06:40

    The above stated problem is due to the missing executenonquery() statement, add this statement in your code

    spojeni.Open();
    prikaz.ExecuteNonQuery();
    
    0 讨论(0)
提交回复
热议问题