插入recorod的问题 [英] problem in inserting recorod

查看:59
本文介绍了插入recorod的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cmd = New SqlCommand("insert into Login1 values" & "(" & "'" & TextBox1.Text & "'" & "," & "'" & TextBox2.Text & "'" & "," & "'" & TextBox3.Text & "'" & "," & TextBox4.Text & "," & TextBox5.Text & "," & "'" & TextBox6.Text & "'" & "," & "'" & TextBox7.Text & "'" & ")", cn)

        cmd.ExecuteNonQuery()
        


       adp.Fill(ds, "Login1")
        MsgBox("Record Inserted....")
        ds.Clear()




当我触发该查询时,记录已两次插入到我的sql数据库中.我无法识别此错误.
因此,请在这个基本内容中为我提供帮助.




while I fire this query then record has been inserted twice in my sql database. I can''t recognize this bug.
so please help me in this basic stuff.

推荐答案

尝试仅为保存值编写

try to write only for save values

cmd = New SqlCommand("insert into Login1 values" & "(" & "''" & TextBox1.Text & "''" & "," & "''" & TextBox2.Text & "''" & "," & "''" & TextBox3.Text & "''" & "," & TextBox4.Text & "," & TextBox5.Text & "," & "''" & TextBox6.Text & "''" & "," & "''" & TextBox7.Text & "''" & ")", cn)
cmd.ExecuteNonQuery()



在执行操作时保存值不是一个好习惯,请始终尝试编写参数化插入命令".
看看数据库参数化插入教程 [



its not a good practice to save values as you are doing,always try to write Parameterized Insert Command.
take a look Database Parameterized Insert Tutorial[^]


这篇关于插入recorod的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆