我想从不同的文本框,标签和组合框中获取用户输入,然后使用SQL CE 3.5将其插入到数据网格中,我尝试将它们作为字符串放入变量中,但我仍然遇到问题这段代码:
Private Sub addToDb_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addToDb_btn.Click
Dim IDVal As String = accIdVal_Lbl.Text
Dim Pwrd As String = accPassVal_Lbl.Text
Dim AcTp As String = accTyp_Cbx.Text
Dim FNm As String = accFrstNm_Txbx.Text
Dim MNm As String = accMidNm_Txbx.Text
Dim LNm As String = accLstNm_Txbx.Text
Dim UsrNm As String = accUsrNm_Txbx.Text
cmd = New SqlCeCommand("INSERT INTO userAccounts(ID, First Name, Middle Name, Last Name, Username, Password, Account Type) VALUES('" & IDVal & "', '" & FNm & "', '" & MNm & "', '" & LNm & "', '" & UsrNm & "', '" & Pwrd & "', '" & AcTp & "')", con)
If con.State = ConnectionState.Closed Then con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Sub
答案 0 :(得分:0)
在[]:
中加上标识符INSERT INTO [userAccounts]([ID], [First Name], [Middle Name], [Last Name], [Username], [Password], [Account Type]