473,385 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.

Please, can someone help me out to solve this error, i've been
searching throughout my codes and yet i didnt succeed in finding the
error!!!!

The Error is:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Data type mismatch in criteria expression.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Data type
mismatch in criteria expression.

Source Error:
Line 19:
Line 20: oDA = New OleDbDataAdapter(sSql, oConn)
Line 21: oDA.Fill(oDS, "product")
Line 22: txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number ")
Line 23: txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
Source File: c:\inetpub\wwwroot\bhavish\products_update.aspx Line:
21

Here is my codes:
__________________________________________________ _____________________________

<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>
<script language="VB" runat=server>
Dim oConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\bhavish_vb_asign\StoresDbs.mdb")
Dim strProduct_Number, strProduct_Type, strProduct,
strProduct_Details, strPrice, strPhoto as string

Sub Insert_Click(ByVal Src As Object, ByVal E As EventArgs)
Dim oDA As OleDbDataAdapter
Dim oDS As New DataSet
Dim sSql As String
oConn.Open()
sSql = "UPDATE product SET Product_Type = '" &
txtProduct_Type.text & "', Product = '" & txtproduct.text & "',
Product_Details = '" & txtProduct_Details.text & "', Price = '" &
txtPrice.text & "', Photo = '" & txtPhoto.text & "' WHERE
Product_Number = '" & txtProduct_Number.Text & "' "
oDA = New OleDbDataAdapter(sSql, oConn)
oDA.Fill(oDS, "product")
txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number ")
txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
txtProduct.Text =
oDS.Tables("product").Rows(0).Item("Product")
txtProduct_Details.Text =
oDS.Tables("product").Rows(0).Item("Product_Detail s")
txtPrice.Text = oDS.Tables("product").Rows(0).Item("Price")
txtPhoto.Text = oDS.Tables("product").Rows(0).Item("Photo")
End Sub

Private Function update(ByVal oConn As OleDbConnection, ByVal
strInsertSQL As String) As Integer
Dim intQueryState As Integer
' Connect to Database
oConn.Open()
'Make the OleDbCommand object
Dim cmdInsert As New OleDbCommand(strInsertSQL, oConn)
intQueryState = cmdInsert.ExecuteNonQuery()
oConn.Close()
Return intQueryState
End Function

Private Function Exists(ByVal oConn As OleDbConnection, ByVal
Value As String, ByVal ValueColumn As String, ByVal Item As String,
ByVal ItemColumn As String, ByVal TableName As String, Optional ByVal
bIsNumeric As Boolean = False) As Integer
Dim blnUserAuthenticated As Boolean = False
' Connect to Database
Dim strSQL As String = "Select * from " & TableName & "
where " & ItemColumn & "='" & Item & "' AND " & ValueColumn & "=" &
IIf(bIsNumeric, Value, "'" & Value & "'")
Dim cmd As New OleDbCommand(strSQL, oConn)
Dim objDataReader As OleDbDataReader
objDataReader = cmd.ExecuteReader()
oConn.Close()

End Function
</script>

__________________________________________________ _____________________________

Apr 10 '07 #1
2 8956
On Apr 10, 2:37 pm, "psychomad" <bhavish1...@gmail.comwrote:
Please, can someone help me out to solve this error, i've been
searching throughout my codes and yet i didnt succeed in finding the
error!!!!

The Error is:

Server Error in '/' Application.
---------------------------------------------------------------------------*-----

Data type mismatch in criteria expression.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Data type
mismatch in criteria expression.

Source Error:

Line 19:
Line 20: oDA = New OleDbDataAdapter(sSql, oConn)
Line 21: oDA.Fill(oDS, "product")
Line 22: txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number ")
Line 23: txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")

Source File: c:\inetpub\wwwroot\bhavish\products_update.aspx Line:
21

Here is my codes:
__________________________________________________ _________________________*____

<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>

<script language="VB" runat=server>
Dim oConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\bhavish_vb_asign\StoresDbs.mdb")
Dim strProduct_Number, strProduct_Type, strProduct,
strProduct_Details, strPrice, strPhoto as string

Sub Insert_Click(ByVal Src As Object, ByVal E As EventArgs)
Dim oDA As OleDbDataAdapter
Dim oDS As New DataSet
Dim sSql As String
oConn.Open()
sSql = "UPDATE product SET Product_Type = '" &
txtProduct_Type.text & "', Product = '" & txtproduct.text & "',
Product_Details = '" & txtProduct_Details.text & "', Price = '" &
txtPrice.text & "', Photo = '" & txtPhoto.text & "' WHERE
Product_Number = '" & txtProduct_Number.Text & "' "

oDA = New OleDbDataAdapter(sSql, oConn)
oDA.Fill(oDS, "product")
txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number ")
txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
txtProduct.Text =
oDS.Tables("product").Rows(0).Item("Product")
txtProduct_Details.Text =
oDS.Tables("product").Rows(0).Item("Product_Detail s")
txtPrice.Text = oDS.Tables("product").Rows(0).Item("Price")
txtPhoto.Text = oDS.Tables("product").Rows(0).Item("Photo")

End Sub

Private Function update(ByVal oConn As OleDbConnection, ByVal
strInsertSQL As String) As Integer
Dim intQueryState As Integer
' Connect to Database
oConn.Open()
'Make the OleDbCommand object
Dim cmdInsert As New OleDbCommand(strInsertSQL, oConn)
intQueryState = cmdInsert.ExecuteNonQuery()
oConn.Close()
Return intQueryState
End Function

Private Function Exists(ByVal oConn As OleDbConnection, ByVal
Value As String, ByVal ValueColumn As String, ByVal Item As String,
ByVal ItemColumn As String, ByVal TableName As String, Optional ByVal
bIsNumeric As Boolean = False) As Integer
Dim blnUserAuthenticated As Boolean = False
' Connect to Database
Dim strSQL As String = "Select * from " & TableName & "
where " & ItemColumn & "='" & Item & "' AND " & ValueColumn & "=" &
IIf(bIsNumeric, Value, "'" & Value & "'")
Dim cmd As New OleDbCommand(strSQL, oConn)
Dim objDataReader As OleDbDataReader
objDataReader = cmd.ExecuteReader()
oConn.Close()

End Function
</script>

__________________________________________________ _________________________*____

The Fill method retrieves the data from the data source using a SELECT
statement. You do an UPDATE, and no SELECT.

Apr 10 '07 #2
On Apr 10, 9:08 pm, "Alexey Smirnov" <alexey.smir...@gmail.comwrote:
On Apr 10, 2:37 pm, "psychomad" <bhavish1...@gmail.comwrote:


Please, can someone help me out to solve this error, i've been
searching throughout my codes and yet i didnt succeed in finding the
error!!!!
The Error is:
Server Error in '/' Application.
---------------------------------------------------------------------------**-----
Data type mismatch in criteria expression.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Data type
mismatch in criteria expression.
Source Error:
Line 19:
Line 20: oDA = New OleDbDataAdapter(sSql, oConn)
Line 21: oDA.Fill(oDS, "product")
Line 22: txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number ")
Line 23: txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
Source File: c:\inetpub\wwwroot\bhavish\products_update.aspx Line:
21
Here is my codes:
__________________________________________________ _________________________**____
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>
<script language="VB" runat=server>
Dim oConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\bhavish_vb_asign\StoresDbs.mdb")
Dim strProduct_Number, strProduct_Type, strProduct,
strProduct_Details, strPrice, strPhoto as string
Sub Insert_Click(ByVal Src As Object, ByVal E As EventArgs)
Dim oDA As OleDbDataAdapter
Dim oDS As New DataSet
Dim sSql As String
oConn.Open()
sSql = "UPDATE product SET Product_Type = '" &
txtProduct_Type.text & "', Product = '" & txtproduct.text & "',
Product_Details = '" & txtProduct_Details.text & "', Price = '" &
txtPrice.text & "', Photo = '" & txtPhoto.text & "' WHERE
Product_Number = '" & txtProduct_Number.Text & "' "
oDA = New OleDbDataAdapter(sSql, oConn)
oDA.Fill(oDS, "product")
txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number ")
txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
txtProduct.Text =
oDS.Tables("product").Rows(0).Item("Product")
txtProduct_Details.Text =
oDS.Tables("product").Rows(0).Item("Product_Detail s")
txtPrice.Text = oDS.Tables("product").Rows(0)..Item("Price")
txtPhoto.Text = oDS.Tables("product").Rows(0)..Item("Photo")
End Sub
Private Function update(ByVal oConn As OleDbConnection, ByVal
strInsertSQL As String) As Integer
Dim intQueryState As Integer
' Connect to Database
oConn.Open()
'Make the OleDbCommand object
Dim cmdInsert As New OleDbCommand(strInsertSQL,oConn)
intQueryState = cmdInsert.ExecuteNonQuery()
oConn.Close()
Return intQueryState
End Function
Private Function Exists(ByVal oConn As OleDbConnection, ByVal
Value As String, ByVal ValueColumn As String, ByVal Item As String,
ByVal ItemColumn As String, ByVal TableName As String, Optional ByVal
bIsNumeric As Boolean = False) As Integer
Dim blnUserAuthenticated As Boolean = False
' Connect to Database
Dim strSQL As String = "Select * from " & TableName & "
where " & ItemColumn & "='" & Item & "' AND " & ValueColumn & "=" &
IIf(bIsNumeric, Value, "'" & Value & "'")
Dim cmd As New OleDbCommand(strSQL, oConn)
Dim objDataReader As OleDbDataReader
objDataReader = cmd.ExecuteReader()
oConn.Close()
End Function
</script>
__________________________________________________ _________________________**____

The Fill method retrieves the data from the data source using a SELECT
statement. You do an UPDATE, and no SELECT.- Hide quoted text -

- Show quoted text -

And check the values you substitute in the query

sSql = "UPDATE product SET Product_Type = '" &
txtProduct_Type.text & "', Product = '" & txtproduct.text & "',
Product_Details = '" & txtProduct_Details.text & "', Price = '" &
txtPrice.text & "', Photo = '" & txtPhoto.text & "' WHERE
Product_Number = '" & txtProduct_Number.Text & "' "

Apr 10 '07 #3

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

Similar topics

0
by: silesius | last post by:
I've been using VS 2003 to develop a webapplication using C#. Today I exported the application to a remote webserver I begun experiencing problems. It's a simple application that retrieves some...
1
by: T8 | last post by:
I have a asp.net (framework 1.1) site interfacing against SQL 2000. It runs like a charm 99% of the time but once in a while I get the following "unspecified error". Sometimes it would resolve by...
0
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves...
3
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...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
0
by: dim mzeura via .NET 247 | last post by:
(Type your message here) -------------------------------- From: dim mzeura I have the same problem too. Please help! System.Data.OleDb.OleDbException: Syntax error (missing operator) in...
1
by: DC | last post by:
Any idea why this code would cause a error? The SQL that gets executed seems to be (using record 1132 as an example) DELETE FROM user_table WHERE ID = '1132'; And the value of...
0
by: chanlichin | last post by:
Select Case (cbMonth.Text) Case "January" Dates = "1" Case "February" Dates = "2" Case "March"
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.