Erreur de syntaxe dans l'instruction INSERT I

Fermé
JavaJ2EE - 5 nov. 2010 à 12:03
 francis - 5 nov. 2010 à 13:38
Bonjour,
J'ai un problème au niveau de l'insertion lors de l'exécution il m'affiche ce message
(Erreur de syntaxe dans l'instruction INSERT INTO.) Voila le code

//declaration
Public cmdRe As New OleDbCommand("select * from Reparation", con)
Public daRe As New OleDbDataAdapter(cmdRe)
Public dsEn As New DataSet
Public cbRe As New OleDbCommandBuilder(daRe)
----
Imports System.Data.OleDb
Public Class Reparation
Dim rb As String
Dim br As String
Dim t() As String

Sub annuler()
Try
ComboBox1.Text = ""
ComboBox2.Text = ""
DateTimePicker1.Text = ""
ComboBox1.Focus()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub Reparation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox2.Items.Add("Chèque")
ComboBox2.Items.Add("Espéce ")
ComboBox2.Items.Add("Autre")
Try
cmdRe.CommandText = "select * from Reparation"
daRe = New OleDbDataAdapter(cmdRe)
cmdRe.Connection() = con
daRe.Fill(dsRe, "Reparation")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
Dim macommande As OleDbCommand = con.CreateCommand
con.Open()
macommande.CommandText = "select Client.nom , Client.prenom from Client"
Dim mareader As OleDbDataReader = macommande.ExecuteReader()
Me.ComboBox1.ResetText()
Me.ComboBox1.Items.Clear()
Do While mareader.Read()
ComboBox1.Items.Add(mareader(0) & " " & mareader(1))
Loop
con.Close()
dsClt.Clear()
daClt.Fill(dsClt, "Client")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
cmdClt.CommandText = "select * from Client"
daClt = New OleDbDataAdapter(cmdClt)
cmdRe.Connection() = con
daClt.Fill(dsClt, "Client")
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

Private Sub Ajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ajouter.Click
If Me.RadioButton1.Checked = True Then
rb = RadioButton1.Text
Else
rb = RadioButton2.Text
End If

t = Me.ComboBox1.Text.Split(" ")

Dim da1 As New OleDbDataAdapter("select Client.id_clt from Client where Client.nom= '" & t(0) & " 'and Client.prenom='" & t(1) & " '", con)
da1.Fill(dsRe, "id_clt")
cbRe = New OleDbCommandBuilder(da1)
da1.Update(dsRe, "Reparation")
row = dsRe.Tables("Reparation").NewRow
row(1) = dsRe.Tables("id_clt").Rows(0)(0)
row(2) = Me.ComboBox2.Text
row(3) = rb
row(4) = Me.DateTimePicker1.Value.Date
dsRe.Tables("Reparation").Rows.Add(row)
cbRe = New OleDbCommandBuilder(daRe)
daRe.Update(dsRe, "Reparation")
dsRe.Clear()
daRe.Fill(dsRe, "Reparation")
MsgBox("l'ajout réussi avec succès")
annuler()
End Sub
Private Sub fermer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
----
Aide moi s'il vous plait pour résoudre mon problèm et merci d'avance
Il ce plante sur cette ligne
" daRe.Update(dsRe, "Reparation") "

A voir également:

1 réponse

affiche ta requete pour voir
0