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

P

psychomad

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_Details")
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>

_______________________________________________________________________________
 
G

Guest

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_Details")
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.
 
G

Guest

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 & "' "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top