1. <tfoot id='9oP6y'></tfoot>
        <bdo id='9oP6y'></bdo><ul id='9oP6y'></ul>

        <i id='9oP6y'><tr id='9oP6y'><dt id='9oP6y'><q id='9oP6y'><span id='9oP6y'><b id='9oP6y'><form id='9oP6y'><ins id='9oP6y'></ins><ul id='9oP6y'></ul><sub id='9oP6y'></sub></form><legend id='9oP6y'></legend><bdo id='9oP6y'><pre id='9oP6y'><center id='9oP6y'></center></pre></bdo></b><th id='9oP6y'></th></span></q></dt></tr></i><div id='9oP6y'><tfoot id='9oP6y'></tfoot><dl id='9oP6y'><fieldset id='9oP6y'></fieldset></dl></div>

        <small id='9oP6y'></small><noframes id='9oP6y'>

        <legend id='9oP6y'><style id='9oP6y'><dir id='9oP6y'><q id='9oP6y'></q></dir></style></legend>
      1. SqlCommand INSERT INTO 查询不执行

        时间:2023-06-05
        <legend id='095ml'><style id='095ml'><dir id='095ml'><q id='095ml'></q></dir></style></legend>
          <tbody id='095ml'></tbody>
          <bdo id='095ml'></bdo><ul id='095ml'></ul>
          <tfoot id='095ml'></tfoot>

          1. <i id='095ml'><tr id='095ml'><dt id='095ml'><q id='095ml'><span id='095ml'><b id='095ml'><form id='095ml'><ins id='095ml'></ins><ul id='095ml'></ul><sub id='095ml'></sub></form><legend id='095ml'></legend><bdo id='095ml'><pre id='095ml'><center id='095ml'></center></pre></bdo></b><th id='095ml'></th></span></q></dt></tr></i><div id='095ml'><tfoot id='095ml'></tfoot><dl id='095ml'><fieldset id='095ml'></fieldset></dl></div>

                • <small id='095ml'></small><noframes id='095ml'>

                  本文介绍了SqlCommand INSERT INTO 查询不执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  大家好,我有这个代码:

                  Hello guys I have got this code:

                  SqlCommand scom = new SqlCommand(
                                                  "INSERT INTO klient(name,surname) 
                                                  values(@kname,@ksurname)", 
                                                  conn);
                  
                  scom.Parameters.AddWithValue("@kname", kname.Text);
                  scom.Parameters.AddWithValue("@ksurname", ksurname.Text);
                  conn.Open();
                  DataTable dt = new DataTable();
                  SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM klient", spojeni);
                  SDA.Fill(dt);
                  conn.Close();
                  

                  它应该从文本框插入数据:kname、ksurname,但它会关闭表单而不在 MS SQL 表客户端中显示它们

                  It should insert data from textboxes: kname, ksurname, but it closes the form without showing them in MS SQL table klient

                  推荐答案

                  缺少 ExecuteNonQuery 调用

                  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...

                  这篇关于SqlCommand INSERT INTO 查询不执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 INSERT 上返回 ID? 下一篇:恒定错误中的新行

                  相关文章

                  最新文章

                    1. <i id='Qjp0v'><tr id='Qjp0v'><dt id='Qjp0v'><q id='Qjp0v'><span id='Qjp0v'><b id='Qjp0v'><form id='Qjp0v'><ins id='Qjp0v'></ins><ul id='Qjp0v'></ul><sub id='Qjp0v'></sub></form><legend id='Qjp0v'></legend><bdo id='Qjp0v'><pre id='Qjp0v'><center id='Qjp0v'></center></pre></bdo></b><th id='Qjp0v'></th></span></q></dt></tr></i><div id='Qjp0v'><tfoot id='Qjp0v'></tfoot><dl id='Qjp0v'><fieldset id='Qjp0v'></fieldset></dl></div>

                      <small id='Qjp0v'></small><noframes id='Qjp0v'>

                      <tfoot id='Qjp0v'></tfoot>

                        <bdo id='Qjp0v'></bdo><ul id='Qjp0v'></ul>

                      <legend id='Qjp0v'><style id='Qjp0v'><dir id='Qjp0v'><q id='Qjp0v'></q></dir></style></legend>