插入命令VB SQL DB

时间:2014-03-31 14:08:56

标签: sql visual-studio-2012

这是我的代码。我希望能够将数据插入到rota表中。编译时,编译时没有错误。单击按钮时出现问题。我得到的错误是:关键字' WHERE'附近的语法不正确。

 Dim Con As SqlConnection
    Dim cmd As New OleDbCommand
    Dim sqlstring As String
    Dim connstring As String
    Dim ds As DataSet
    Dim da As SqlDataAdapter



    connstring = "Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Assignment.mdf;Integrated Security=True;Connect Timeout=30"

    Con = New SqlConnection(connstring)
    Con.Open()


    sqlstring = ("Insert into Rota WHERE Id ='" & DateTimePicker1.Value & "' and Monday ='" & mon & "' and Tuesday ='" & tues & "'and Wednesday ='" & wed & "'and Thursday ='" & thur & "'and Friday ='" & fri & "'and Saturday ='" & sat & "'and Sunday ='" & sun & "' and UserID ='" & cboname.SelectedIndex & "'")
    da = New SqlDataAdapter(sqlstring, Con)
    ds = New DataSet
    da.Fill(ds, "Rota")

0 个答案:

没有答案