470,641 Members | 2,453 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

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 8770
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by NicK chlam via DotNetMonster.com | last post: by
reply views Thread by dim mzeura via .NET 247 | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.