When I am truing to insert data to MS Access Database Table using oledb 4.0 I found an error
The statement
private void btnPrint_Click(object sender, EventArgs e)
{
intYear = DateTime.Now.Month;
strYear = intYear.ToString();
strID = cmbPatID.Text;
strPatID = strYear + strID;
strName = txtPatName.Text;
strTitle = cmbTitle.Text;
strPatName = strTitle + strName;
strAge = txtAge.Text;
strPatAdd = txtAddress.Text;
strHae02 = txtHae02.Text; strRbc02 = txtRbc02.Text; strPcv02 = txtPcv02.Text; strMcv02 = txtMcv02.Text;
strMch02 = txtMch02.Text; strMchc02 = txtMchc02.Text; strPlat02 = txtPlat02.Text; strWbc02 = txtWbc02.Text;
strNeu02 = txtNeu02.Text; strLym02 = txtLym02.Text; strEos02 = txtEos02.Text; strMono02 = txtMono02.Text;
strBas02 = txtBas02.Text;
strTestDate = tDate.ToString();
strTestTime = tTime.ToString();
OleDbComm.Connection = OleDbConn;
OleDbComm.CommandType = CommandType.Text;
OleDbComm.CommandText = @"INSERT INTO Full_Blood_Count ([PatID],[PatName],[PatAge],[PatAddress],[TDate],[TTime],[Hae],[Hae2],[Rbc],[Rbc2],[Pcv],[Pcv2],[Mcv],[Mcv2],[Mchc],[Mchc2],[Plat],[Plat2],[Wbc],[Wbc2],[Neu],[Neu2],[Lym],[Lym2],[Eos],[Eos2],[Mono],[Mono2],[Bas],[Bas2]) VALUES ('" + strPatID + "','" + strPatName + "','" + strAge + "','" + strPatAdd + "','" + strTestDate + "','" + strTestTime + "','" + dblHaemo + "','" + strHae02 + ",'" + dblRbc + "','" + strRbc02 + "','" + dblPcv + "','" + strPcv02 + "','" + dblMcv + "','" + strMcv02 + "','" + dblMch + "','" + strMch02 + "','" + dblMchc + "','"+ strMchc02 + "','" + dblPlat + "','"+ strPlat02 + "','" + dblWbc + "','" + strWbc02 + "','" + dblNeu + "','" + strNeu02 + "','" + dblLym + "','" + strLym02 + "','" + dblEos + "','" + strEos02 + "','" + dblMono + "','" + strMono02 + "','" + dblBas + "','" + strBas02 + "')";
OleDbComm.ExecuteNonQuery();
OleDbConn.Close();
I got the error at
OleDbComm.ExecuteNonQuery();
The error is
System.Data.OleDb.OleDbException was unhandled
Message="Syntax error (missing operator) in query expression ''*,'45','*','45','','5','*','5','*','5','*','5','*','5','*','5','*','5','*','5',' ','5','*','5','*')'."
Source="Microsoft JET Database Engine"
ErrorCode=-2147217900
StackTrace:
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Lanka_Lab.frmFulBldCuntDet.btnPrint_Click(Object sender, EventArgs e) in C:\Users\Administrator\Documents\Visual Studio 2008\Projects\Lanka_Lab\Lanka_Lab\Form1.cs:line 831
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Lanka_Lab.Program.Main() in C:\Users\Administrator\Documents\Visual Studio 2008\Projects\Lanka_Lab\Lanka_Lab\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I cannot understand what is the error meaning
If someone can please solve this problem
Thank You!