Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.

Reply
Thread Tools

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

 
 
psychomad
Guest
Posts: n/a
 
      04-10-2007
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>

__________________________________________________ _____________________________

 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-10-2007
On Apr 10, 2:37 pm, "psychomad" <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-10-2007
On Apr 10, 9:08 pm, "Alexey Smirnov" <(E-Mail Removed)> wrote:
> On Apr 10, 2:37 pm, "psychomad" <(E-Mail Removed)> wrote:
>
>
>
>
>
> > 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 & "' "

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL Type Mismatch error indexed name returns a value whose type does not match programmingzeal VHDL 0 05-06-2012 06:38 AM
OleDbException: Data type mismatch in criteria expression. Bobby Edward ASP .Net 1 03-05-2008 01:17 PM
ViewState passed ID [OleDbException (0x80040e07): Data type mismatchin criteria expression.] error? DC ASP .Net 1 09-20-2007 11:49 AM
Error: Data type mismatch in criteria expression Jack ASP General 7 01-04-2005 05:25 PM
Error in dynamic sql: Data type mismatch in criteria Jack ASP General 7 12-28-2004 04:09 AM



Advertisments