-1
我遇到了將數據插入到Access數據庫的問題,這對我所有其他表格都適用,但它只是不想插入我的一個表,這可能是一些愚蠢的語法錯誤,完全讓我拉我的頭髮,有人可以請告知我可能做錯了,請不要介意我的代碼我是一個完整的新手。每當我運行代碼時,我得到一個語法錯誤插入語句錯誤。當我在Access中運行它時,它插入數據沒有問題,但是當我在VB中運行它時,出現語法錯誤,我不知道這裏出現了什麼問題,你能也許建議插入到語句中的語法錯誤 - 在Access數據庫中不在VS2010中工作vb prog
Sub Insert_NewUser(ByVal txtUserID As TextBox, ByVal txtUser_Name As TextBox, ByVal txtFullName As TextBox, ByVal txtPassword As TextBox, ByVal txtPassword2 As TextBox, ByVal cmbUser_Type As ComboBox)
Dim UserID, User_Name As String
Dim FullName, Password, Password2 As String
Dim User_Type As String
UserID = txtUserID.Text
User_Name = txtUser_Name.Text
FullName = txtFullName.Text
Password = txtPassword.Text
Pass_confirmed= txtPassword2.Text
User_Type = cmbUser_Type.SelectedItem
con.Open()
Dim Sql As String = "Insert INTO Users(UserID,User_Name,FullName,Password,Pass_confirmed,User_Type)VALUES(@UserID,@User_Name,@FullName,@Password,@Pass_confirmed,@User_Type)"
Using cmd As New OleDbCommand(Sql, con)
cmd.Parameters.AddWithValue("@UserID", UserID)
cmd.Parameters.AddWithValue("@User_Name", User_Name)
cmd.Parameters.AddWithValue("@FullName", FullName)
cmd.Parameters.AddWithValue("@Password", Password)
cmd.Parameters.AddWithValue("@Pass_confirmed", Pass_confirmed)
cmd.Parameters.AddWithValue("@User_Type", User_Type)
cmd.ExecuteNonQuery()
End Using
con.Close()
End Sub
請更新與語法錯誤的問題。 – Bugs