插入命令VB实际上不插入数据?

时间:2014-04-23 19:03:24

标签: sql sql-server vb.net visual-studio-2012

我有以下代码向DB添加记录。代码执行正常,但是当我查看数据库时,没有添加数据!任何帮助非常感谢:

Dim Con As SqlConnection
Dim cmd As New SqlCommand
Dim connstring As String
connstring = "Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Assignment.mdf;Integrated Security=True;Connect Timeout=30"
Con = New SqlConnection(connstring)
Con.Open()
cmd = New SqlCommand("Insert into Rota ([Id],[Monday],[Tuesday],[Wednesday],[Thursday],[Friday],[Saturday],[Sunday],[UserID]) Values('" & chosen & "','" & mon & "','" & tues & "','" & wed & "','" & thur & "','" & fri & "','" & sat & "','" & sun & "','" & user & "')", Con)
cmd.ExecuteNonQuery()
MsgBox("done")
Con.Close()

0 个答案:

没有答案