Tha_Boss
asked on
SqlException (VB .NET) with Access 2000
(My english skill is bad, so sorry for the quality of the text)
I have about 8 Access table that I join with my DataTable in VB .NET and it works perfectly. But when I want to do the DataSet for the Transaction table an SqlException is trhow :
Private Function monDatasetTransaction() As Boolean
Dim OK As Boolean = True
Try
'Cree un lien entre la table clients et la table du dataset en mémoire
DATransaction = New SqlDataAdapter( _
"SELECT * FROM Transaction", Connection)
CBTransaction = New SqlCommandBuilder(DATransa ction)
CBTransaction.GetUpdateCom mand()
DATransaction.Fill(DSClubV ideo, "Transaction")
DTTransaction = DSClubVideo.Tables("Transa ction")
Catch e As SqlException
OK = False
MsgBox(e.ToString) 'The error comes from here....................
Catch e As Exception
OK = False
MsgBox(e.Message, MsgBoxStyle.Critical, "Erreur Général")
End Try
Return OK
End Function
The error: System.Data.SqlClient.SqlE xception: Incorrect Syntax Near the Keyword 'Transaction'............. .......... .......... .......... .......... ......
Please help me, because I really don't know what is the problem with this one, all others DataTable works perfectly.
Thanx,
Mr. Tha_Boss
I have about 8 Access table that I join with my DataTable in VB .NET and it works perfectly. But when I want to do the DataSet for the Transaction table an SqlException is trhow :
Private Function monDatasetTransaction() As Boolean
Dim OK As Boolean = True
Try
'Cree un lien entre la table clients et la table du dataset en mémoire
DATransaction = New SqlDataAdapter( _
"SELECT * FROM Transaction", Connection)
CBTransaction = New SqlCommandBuilder(DATransa
CBTransaction.GetUpdateCom
DATransaction.Fill(DSClubV
DTTransaction = DSClubVideo.Tables("Transa
Catch e As SqlException
OK = False
MsgBox(e.ToString) 'The error comes from here....................
Catch e As Exception
OK = False
MsgBox(e.Message, MsgBoxStyle.Critical, "Erreur Général")
End Try
Return OK
End Function
The error: System.Data.SqlClient.SqlE
Please help me, because I really don't know what is the problem with this one, all others DataTable works perfectly.
Thanx,
Mr. Tha_Boss
Hi
try to debug application and find the exact line no for error.
mufaddal
try to debug application and find the exact line no for error.
mufaddal
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok,
here's the complete exception message that I get now:
Error on update... System.Data.SqlClient.SqlE xception: Incorrect syntax near the keyword 'Transaction'.
at System.Common.DbDataAdapte r.Update(D ataRow[] dataRows, DataTableMapping tableMapping)
at System.Common.DbDataAdapte r.Update(D ataTable datatable)
at ClubVideo.Transaction.comm itChangeme ntsTransac tion() in ...
And I'll give you the rest of the code:
Private Sub BtnAjouterLocation_Click(B yVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAjouterLocation.Click
If monDatasetLocation() Then
AjouterLocationTransaction ()
Dim Reponse As MsgBoxResult
Reponse = MsgBox("Voulez-vous ajoute", vbOKCancel, "Titre")
Select Case Reponse
Case vbOK
If monDatasetTransaction() Then
Dim Etat As String
Etat = "Location"
AjouterTransaction(Etat)
End If
Case vbCancel
End Select
End If
End Sub
'The code of this function is in my first message above.
Private Function monDatasetTransaction() As Boolean
Private Sub AjouterTransaction(ByVal transEtat As String)
Try
Dim drRows As DataRowCollection
drRows = DTTransaction.Rows
Dim objNewRow = DTTransaction.NewRow()
If transEtat = "Location" Then
objNewRow("NO_TRANSACTION" ) = txtNoTransaction.Text
objNewRow("DATE_TRANSACTIO N") = txtDateLocation.Text
objNewRow("DATE_RETOUR") = txtDateRetour.Text
objNewRow("ID_CLIENT") = msktxtIdClient.Text
Dim vraiIdItem As TexteValide = New TexteValide(msktxtIdItemLo cation.Tex t)
objNewRow("ID_ITEM") = vraiIdItem.ToString
objNewRow("DUREE") = cboDuree.Text
End If
drRows.Add(objNewRow)
commitChangementsTransacti on()
Catch sql As SqlException
MsgBox("Erreur")
End Try
End Sub
Private Sub commitChangementsTransacti on()
Try
DATransaction.Update(DTTra nsaction)
Catch e As SqlException
MsgBox("qqqqqqqqqqqqqqqqqq qqqqqqqqqq q..." & e.ToString)
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "Erreur Général.")
End Try
End Sub
Thanx all of you,
Tha_Boss
here's the complete exception message that I get now:
Error on update... System.Data.SqlClient.SqlE
at System.Common.DbDataAdapte
at System.Common.DbDataAdapte
at ClubVideo.Transaction.comm
And I'll give you the rest of the code:
Private Sub BtnAjouterLocation_Click(B
If monDatasetLocation() Then
AjouterLocationTransaction
Dim Reponse As MsgBoxResult
Reponse = MsgBox("Voulez-vous ajoute", vbOKCancel, "Titre")
Select Case Reponse
Case vbOK
If monDatasetTransaction() Then
Dim Etat As String
Etat = "Location"
AjouterTransaction(Etat)
End If
Case vbCancel
End Select
End If
End Sub
'The code of this function is in my first message above.
Private Function monDatasetTransaction() As Boolean
Private Sub AjouterTransaction(ByVal transEtat As String)
Try
Dim drRows As DataRowCollection
drRows = DTTransaction.Rows
Dim objNewRow = DTTransaction.NewRow()
If transEtat = "Location" Then
objNewRow("NO_TRANSACTION"
objNewRow("DATE_TRANSACTIO
objNewRow("DATE_RETOUR") = txtDateRetour.Text
objNewRow("ID_CLIENT") = msktxtIdClient.Text
Dim vraiIdItem As TexteValide = New TexteValide(msktxtIdItemLo
objNewRow("ID_ITEM") = vraiIdItem.ToString
objNewRow("DUREE") = cboDuree.Text
End If
drRows.Add(objNewRow)
commitChangementsTransacti
Catch sql As SqlException
MsgBox("Erreur")
End Try
End Sub
Private Sub commitChangementsTransacti
Try
DATransaction.Update(DTTra
Catch e As SqlException
MsgBox("qqqqqqqqqqqqqqqqqq
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "Erreur Général.")
End Try
End Sub
Thanx all of you,
Tha_Boss
ASKER
I modify it like that and it still don't work:
DATransaction = New SqlDataAdapter( _
"SELECT * FROM [Transaction]", Connection)
CBTransaction = New SqlCommandBuilder(DATransa ction)
DATransaction.UpdateComman d = CBTransaction.GetUpdateCom mand()
DATransaction.Fill(DSClubV ideo, "Transaction")
DTTransaction = DSClubVideo.Tables("Transa ction")
DATransaction = New SqlDataAdapter( _
"SELECT * FROM [Transaction]", Connection)
CBTransaction = New SqlCommandBuilder(DATransa
DATransaction.UpdateComman
DATransaction.Fill(DSClubV
DTTransaction = DSClubVideo.Tables("Transa
ASKER
Thanx all of you,
I just change the name of my table I replace Transaction by AllTransaction and it works. It was reallly because of the keyword Transaction within SQl.
Thanx all,
Tha_Boss
I just change the name of my table I replace Transaction by AllTransaction and it works. It was reallly because of the keyword Transaction within SQl.
Thanx all,
Tha_Boss
DATransaction = New SqlDataAdapter()
DATransaction.SelectComman
CBTransaction = New SqlCommandBuilder(DATransa
DATransaction.UpdateComman
' open the conn if close
Regards,
~ fantasy ~