Glenvn
03-26-2011, 03:59 PM
Dear All,
I have the following code:
Imports System.Data.OleDb
Public Class frmBrucS19Calc
Inherits System.Windows.Forms.Form
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source=|DataDirectory|\VaccineInfo.accdb;")
Dim ID As Integer = 0
Dim Ds As New DataSet()
Dim Nextb As Long
Dim PrevB As Long
Dim TotalC As Long
Dim dt As New DataTable("tblBrucellaS19")
Dim rs As OleDb.OleDbDataAdapter
Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
con.Open()
Dim rs As New OleDb.OleDbCommand(
"INSERT INTO tblBrucellaS19 (MFCSBatchNo, FinalBatchNo, Doses, TASBatchNo) VALUES ('" & txtMFCS.Text & "','" & txtFinBatchNum.Text & "','" &
txt220.Text & "','" & txtTASBatch.Text & ")", con)
rs.ExecuteNonQuery()
con.Close()
LoadGrid("")
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I get the following error after clicking cmdsave to insert data into the database:
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217900
Message=Syntax error in string in query expression ''80)'.
Source=Microsoft Office Access Database Engine
Here is something obvious wrong, yet I cannot see it....''80)' refers to the value of txtTASBatch.Text. It is supposed to be "80".
Any ideas?
TIA
I have the following code:
Imports System.Data.OleDb
Public Class frmBrucS19Calc
Inherits System.Windows.Forms.Form
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source=|DataDirectory|\VaccineInfo.accdb;")
Dim ID As Integer = 0
Dim Ds As New DataSet()
Dim Nextb As Long
Dim PrevB As Long
Dim TotalC As Long
Dim dt As New DataTable("tblBrucellaS19")
Dim rs As OleDb.OleDbDataAdapter
Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
con.Open()
Dim rs As New OleDb.OleDbCommand(
"INSERT INTO tblBrucellaS19 (MFCSBatchNo, FinalBatchNo, Doses, TASBatchNo) VALUES ('" & txtMFCS.Text & "','" & txtFinBatchNum.Text & "','" &
txt220.Text & "','" & txtTASBatch.Text & ")", con)
rs.ExecuteNonQuery()
con.Close()
LoadGrid("")
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I get the following error after clicking cmdsave to insert data into the database:
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217900
Message=Syntax error in string in query expression ''80)'.
Source=Microsoft Office Access Database Engine
Here is something obvious wrong, yet I cannot see it....''80)' refers to the value of txtTASBatch.Text. It is supposed to be "80".
Any ideas?
TIA