這是我在VB.NET中的代碼。我無法在我的acces數據庫中插入值
我的try catch表示指令INSERT INTO
中有語法錯誤。我不知道我的INSERT發生了什麼。我搜索了一個多小時的錯誤...我不是VB.NET的專家,我在C#中更好,但是我仍然需要在VB中執行此操作...
感謝您幫助我!
Sub InsertRecord()
Dim conClasf As OleDbConnection
Dim cmdClasf As New OleDbCommand
Dim strClasf As String
Dim strSQL As String
Dim intRowsAff As Integer
lblErrMsg.Text = ""
lblRecsAff.Text = ""
strClasf = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
server.mappath("BecsEtMuseaux.mdb") & ";"
conClasf = New OleDbConnection(strClasf)
conClasf.Open
Randomize
strSQL = "INSERT INTO client (" & _
"UserName, " & _
"Prenom, " & _
"Nom, " & _
"password, " & _
"mail, " & _
"Addresse, " & _
"Ville, " & _
"PostalCode, " & _
"Province, " & _
"Pays, " & _
"AnimalGenre, " & _
"NomAnimal, " & _
"Race, " & _
") VALUES ('" & _
Replace(txtUserName.Text, "'", "''") & _
"', '" & _
Replace(txtPrénom.Text, "'", "''") & _
"', '" & _
Replace(txtNom.Text, "'", "''") & _
"', '" & _
Replace(txtPass.Text, "'", "''") & _
"', '" & _
Replace(txtMail.Text, "'", "''") & _
"', " & _
Replace(txtAdresse.Text, "'", "''") & _
"', " & _
Replace(txtVille.Text, "'", "''") & _
"', " & _
Replace(txtPostal.Text, "'", "''") & _
"', " & _
Replace(txtProvince.Text, "'", "''") & _
"', " & _
Replace(txtPays.Text, "'", "''") & _
"', " & _
Replace(rblAnimal.Text, "'", "''") & _
"', " & _
Replace(txtAnimal.Text, "'", "''") & _
"', " & _
Replace(txtRace.Text, "'", "''")
cmdClasf = New OleDbCommand(strSQL, conClasf)
Try
intRowsAff = cmdClasf.ExecuteNonQuery()
Catch ex As Exception
lblErrMsg.Text = ex.Message
End Try
lblRecsAff.Text = intRowsAff & " record(s) inserted"
conClasf.Close
End Sub
這不是SqlDbType這是訪問你肯定這將工作絲毫 – FrankSharp 2011-12-16 05:17:04