Erreur de syntaxe dans l'Instruction INSERT INTO dans vb.net
Je suis arriver et erreur de syntaxe dans l'instruction insert into. IF
déclaration est fonctionne très bien juste obtenir cette erreur lorsqu'il tente de sauver les informations
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
If txt12Per.Text >= TextBox12.Text And txtGPer.Text >= TextBox11.Text And TextBox1.Text >= TextBox10.Text Then
Try
'Dim da As OleDb.OleDbDataAdapter
Dim dbprovider As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Taher\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\Database1.accdb;Persist Security Info=False;"
Me.con = New OleDb.OleDbConnection()
con.ConnectionString = dbprovider
con.Open()
Dim sqlquery As String = "INSERT INTO MCAscheduled (URno,SName,hsc,gper,pgper,pstatus,cname,hrname,position,hscinter,ginter,pginter,comments)" + "VALUES (" & CInt(txtUrn.Text) & ",'" & txtName.Text & "'," & CInt(txt12Per.Text) & "," & CInt(txtGPer.Text) & "," & CInt(TextBox1.Text) & ",'" & ComboBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & ComboBox4.Text & "'," & CInt(TextBox12.Text) & "," & CInt(TextBox11.Text) & "," & CInt(TextBox10.Text) & ",'" & TextBox9.Text & "');"
Dim sqlcommand As New OleDb.OleDbCommand(sqlquery)
With sqlcommand
.CommandText = sqlquery
.Connection = con
.ExecuteNonQuery()
con.Close()
txtUrn.Text = ""
txt12Per.Text = ""
txtGPer.Text = ""
txtName.Text = ""
cmbNameofGCourse.Text = ""
End With
MsgBox("Record Added")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Else
MsgBox("Student Not eligible for the requested company")
End If
End Sub
Quelqu'un peut-il m'aider avec cela....
- Quel message d'erreur? Où?
- l'obtention de cette erreur à la ligne 64 qui est .executenonquery mais comme le dit Erreur de Syntaxe dans l'instruction INSERT INTO
- les modifications effectuées, toujours la même erreur.....:( code de mise à jour
Vous devez vous connecter pour publier un commentaire.
Vous voulez insérer dans 13 colonnes, mais de fournir seulement 11 valeurs!
Vous avez 13 champs pour insérer des valeurs dans, mais seulement 11 valeurs.
Utiliser des crochets et il fonctionne parfaitement.
avait pour modifier la position du champ à quelque chose d'autre je ne sais pas pourquoi, mais il a travaillé