Asked by:
OleDb Exception : Data type mismatch in criteria expression

Question
-
I am using VB 2008 & MS Access Database to create a WinForm Application.
I have a primary key column set to AutoNumber in Database
I am able to save 1st Record correctly but while triying to Save second one this error occars. Reopening the form with same new data again saves it correctly but same thing again that you can not add another new one.
Here the Code
Private
Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
IsNumeric(txtAmount.Text)
AndAlso Not txtAmount.Text < 100000 ThentaFormNo404Entries.Connection.Open()
bsFormNo404Entries.Position = bsFormNo404Entries.Find(
"SrNo", iNewId)Beep()
MDI.lblStatusLabel1.Text =
"RECORD ADDED / UPDATED"TurnControlsToEnableDesable(
True)MDI.lblStatusLabel1.Text =
"PLEASE CHECK ALL FIELDS"taFormNo404Entries.Connection.Close()
Tuesday, April 12, 2011 1:07 AM
All replies
-
Hi Sandeep,
What error are you getting in the exception? Is it related to the primary key?
It maybe possible that you are providing a value for the autonumber column.
Wednesday, May 18, 2011 7:16 AM -
Wednesday, May 18, 2011 7:34 PM
-
Here is the link for My Project
http://cid-ff10e426c5c28b48.office.live.com/self.aspx/.Public/Projects.rar
Change the Connection string in app.config file to the location of access file in you Computer & start Debugging
Goto Menu Entry --> Goods Outward
& try to add new data entry your 1st Entry will be saved without any error however with the second one you will get Cocurrency Error.
SANDEEP
Wednesday, May 18, 2011 7:37 PM -
I also have this issues in C# code:
My connectionString is :
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=[FileName]
;Mode=Share Deny Write;Extended Properties=\"HDR=YES\";Jet OLEDB:Engine Type=37";
using (OleDbConnection conn = new OleDbConnection(strCon.Replace("[FileName]", filename))) { OleDbCommand commond = conn.CreateCommand(); conn.Open(); foreach(CaseInfo cinfo in CaseList) { commond.CommandText = "update [" + SheetName+ "$] set ExistBug='" + cinfo.BugInfo + "' where Test_ID = '" + cinfo.CaseId + "'"; commond.ExecuteNonQuery(); } conn.Close(); }
Who can give a help !
Thursday, March 22, 2012 1:55 AM