473,651 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error when trying to add an Access DB Record containing a Long Integer type field using OLEDB in ADO.Net

Hi All,

I am trying to add a record to a datatable that is connected to an Access
database. I had no trouble with string and date fields, but for this
record, I have two Long Integer field types and I get the following error:

"Data type mismatch in criteria expression."

I am using OleDbType.Integ er as the type which matched the Int32 size for
the Long Integer in Access, but I can't seem to get past the error.

Please Help!!

Bob Hanson
Nov 17 '05 #1
4 3656
Bob Hanson Wrote:

Yes with the same error.

Thanks for asking.

Regards,

Bob Hanson

"Tu-Thach" <tu*****@yahoo. com> wrote in message
news:09******** *************** *****@phx.gbl.. .
Have you tried to use OleDbType.BigIn t instead of
OleDbType.Integ er?

Tu-Thach
-----Original Message-----
Hi All,

I am trying to add a record to a datatable that is

connected to an Access
database. I had no trouble with string and date fields,

but for this
record, I have two Long Integer field types and I get the

following error:

"Data type mismatch in criteria expression."

I am using OleDbType.Integ er as the type which matched

the Int32 size for
the Long Integer in Access, but I can't seem to get past

the error.

Please Help!!

Bob Hanson
.

Nov 17 '05 #2
Could you post the code that inserts the data into the
table?

Tu-Thach
Nov 17 '05 #3
Here it is:

Public Function AddNewEroutingP rocessStepsDBRe cords(ByVal
strEroutingTemp lateName As String, ByVal strErouting As String) As
Boolean
Dim strQuery As String = "Select
Routing_Name,St ep_Number,Group _Name,Notify_On ly_Flag,Step_De scription,St
ep_Rejected_Pre vious_Step_Numb er From Routing_Templat e_Step_Data Where
Routing_Name = '" + strEroutingTemp lateName + "'"
Dim OLEDataAdapter As New OleDb.OleDbData Adapter(strQuer y,
cnSimpleEroutin gOleDb)
Dim TempDataTable As New DataTable("Rout ing_Template_St ep_Data")
Dim iResult As Integer
Try
iResult = OLEDataAdapter. Fill(TempDataTa ble)
Dim TempDataRows(), TempDataRow As DataRow
Dim TempRowCounter As Integer
TempDataRows = TempDataTable.S elect
If TempDataRows.Le ngth > 0 Then
Dim lStepNumber, lStepRejectedPr eviousStepNumbe r As Long
Dim strGroupName, strStepDescript ion As String
Dim bNotifyOnlyFlag As Boolean
Dim strInsertRecord Query As String = "Insert Into
Routing_Process _Step_Data(Uniq ue_Routing_Numb er,Step_Number, Group_Name,N
otify_Only_Flag ,Step_Descripti on,Step_Rejecte d_Previous_Step _Number)
Values(@Unique_ Routing_Number, @Step_Number,@G roup_Name,@Noti fy_Only_Flag
,@Step_Descript ion,@Step_Rejec ted_Previous_St ep_Number)"
Dim InsertOledbComm and As New
OleDb.OleDbComm and(strInsertRe cordQuery, cnSimpleEroutin gOleDb)
For TempRowCounter = 0 To TempDataRows.Le ngth - 1
TempDataRow = TempDataRows(Te mpRowCounter)
lStepNumber = CLng(TempDataRo w("Step_Number" ))
lStepRejectedPr eviousStepNumbe r =
CLng(TempDataRo w("Step_Rejecte d_Previous_Step _Number"))
strGroupName = CStr(TempDataRo w("Group_Name") )
strStepDescript ion =
CStr(TempDataRo w("Step_Descrip tion"))
bNotifyOnlyFlag =
CBool(TempDataR ow("Notify_Only _Flag"))

InsertOledbComm and.Parameters. Add("@Unique_Ro uting_Number",
OleDb.OleDbType .VarChar, 20).Value = strErouting
InsertOledbComm and.Parameters. Add("@Step_Numb er",
OleDb.OleDbType .Integer).Value = CInt(lStepNumbe r)

InsertOledbComm and.Parameters. Add("@Step_Reje cted_Previous_S tep_Number",
OleDb.OleDbType .Integer).Value = CInt(lStepRejec tedPreviousStep Number)
InsertOledbComm and.Parameters. Add("@Group_Nam e",
OleDb.OleDbType .VarChar, 30).Value = strGroupName

InsertOledbComm and.Parameters. Add("@Step_Desc ription",
OleDb.OleDbType .VarChar, 255).Value = strStepDescript ion

InsertOledbComm and.Parameters. Add("@Notify_On ly_Flag",
OleDb.OleDbType .Boolean).Value = bNotifyOnlyFlag
InsertOledbComm and.Connection. Open()
InsertOledbComm and.ExecuteNonQ uery()
Next
End If
StopSimpleErout ingDBConnection ()
Return True
Catch e As Exception
Return False
End Try
End Function

Thanks for working on this,

Bob Hanson
CEO
Custom Programming Unlimited LLC

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
Robert,
I look at your code below and saw that when you add the parameters to
your Insert statement, you added them out of order. You should add
the parameters in the same order as they are defined in your statement
i.e.

@Unique_Routing _Number,@Step_N umber,@Group_Na me,@Notify_Only _Flag
,@Step_Descript ion,@Step_Rejec ted_Previous_St ep_Number

That is because OleDb uses positional parameters and not named
parameters like SqlClient.

Hope that helps.
Tu-Thach

Robert Hanson <ro*****@cpuand simplepdm.com> wrote in message news:<#d******* *******@TK2MSFT NGP11.phx.gbl>. ..
Here it is:

Public Function AddNewEroutingP rocessStepsDBRe cords(ByVal
strEroutingTemp lateName As String, ByVal strErouting As String) As
Boolean
Dim strQuery As String = "Select
Routing_Name,St ep_Number,Group _Name,Notify_On ly_Flag,Step_De scription,St
ep_Rejected_Pre vious_Step_Numb er From Routing_Templat e_Step_Data Where
Routing_Name = '" + strEroutingTemp lateName + "'"
Dim OLEDataAdapter As New OleDb.OleDbData Adapter(strQuer y,
cnSimpleEroutin gOleDb)
Dim TempDataTable As New DataTable("Rout ing_Template_St ep_Data")
Dim iResult As Integer
Try
iResult = OLEDataAdapter. Fill(TempDataTa ble)
Dim TempDataRows(), TempDataRow As DataRow
Dim TempRowCounter As Integer
TempDataRows = TempDataTable.S elect
If TempDataRows.Le ngth > 0 Then
Dim lStepNumber, lStepRejectedPr eviousStepNumbe r As Long
Dim strGroupName, strStepDescript ion As String
Dim bNotifyOnlyFlag As Boolean
Dim strInsertRecord Query As String = "Insert Into
Routing_Process _Step_Data(Uniq ue_Routing_Numb er,Step_Number, Group_Name,N
otify_Only_Flag ,Step_Descripti on,Step_Rejecte d_Previous_Step _Number)
Values(@Unique_ Routing_Number, @Step_Number,@G roup_Name,@Noti fy_Only_Flag
,@Step_Descript ion,@Step_Rejec ted_Previous_St ep_Number)"
Dim InsertOledbComm and As New
OleDb.OleDbComm and(strInsertRe cordQuery, cnSimpleEroutin gOleDb)
For TempRowCounter = 0 To TempDataRows.Le ngth - 1
TempDataRow = TempDataRows(Te mpRowCounter)
lStepNumber = CLng(TempDataRo w("Step_Number" ))
lStepRejectedPr eviousStepNumbe r =
CLng(TempDataRo w("Step_Rejecte d_Previous_Step _Number"))
strGroupName = CStr(TempDataRo w("Group_Name") )
strStepDescript ion =
CStr(TempDataRo w("Step_Descrip tion"))
bNotifyOnlyFlag =
CBool(TempDataR ow("Notify_Only _Flag"))

InsertOledbComm and.Parameters. Add("@Unique_Ro uting_Number",
OleDb.OleDbType .VarChar, 20).Value = strErouting
InsertOledbComm and.Parameters. Add("@Step_Numb er",
OleDb.OleDbType .Integer).Value = CInt(lStepNumbe r)

InsertOledbComm and.Parameters. Add("@Step_Reje cted_Previous_S tep_Number",
OleDb.OleDbType .Integer).Value = CInt(lStepRejec tedPreviousStep Number)
InsertOledbComm and.Parameters. Add("@Group_Nam e",
OleDb.OleDbType .VarChar, 30).Value = strGroupName

InsertOledbComm and.Parameters. Add("@Step_Desc ription",
OleDb.OleDbType .VarChar, 255).Value = strStepDescript ion

InsertOledbComm and.Parameters. Add("@Notify_On ly_Flag",
OleDb.OleDbType .Boolean).Value = bNotifyOnlyFlag
InsertOledbComm and.Connection. Open()
InsertOledbComm and.ExecuteNonQ uery()
Next
End If
StopSimpleErout ingDBConnection ()
Return True
Catch e As Exception
Return False
End Try
End Function

Thanks for working on this,

Bob Hanson
CEO
Custom Programming Unlimited LLC

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
10126
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought I should give back to the community by posting our findings. Thanks you all for all your help till now by posting problems and their solutions. ~Abhijit
2
17513
by: Andy Davis | last post by:
Dear Group I am trying to automate process of adding a new record id in my form using the following code when the user clicks the "Add New Record" button. For example if the last record id is "2005001" then I want to increment this by one so that new value is "2005002" and place it in the record id field for the new record on the form. I've tried using the following code but get the message "Overflow" when I run the code. Can't find on...
4
2852
by: Troy | last post by:
We recently installed the .Net framework on a windows 2000 server. Shortly after that we experienced intermitant problems running a web based program that accesses an Access 2002 database. The intranet .asp program works, but as soon as it tries to access the database for normal users, it gives us an "unspecified error" and that it can't access the data base. As the administrator, I found my access was relatively stable. Anyone else...
3
8823
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I don't think I made any changes to either page other than changing the user control that creates the header). Server Error in '/myApp' Application. ---------------------------------------------------------------------------- ----
1
8330
by: Reza Nabi | last post by:
Dear All: I have been developing ASP.NET application on MS Access database using ODBC. When I was trying to save more than 255 chars in a Memo field I got the following error. ERROR Invalid precision value Below is the code snippet of two function where it is breaking. Any advice on this would be greatly appreciated.
18
4727
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
6
3449
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
2
19455
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.