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

Discussion in 'ASP .Net' started by psychomad, Apr 10, 2007.

  1. psychomad

    psychomad 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>

    _______________________________________________________________________________
    psychomad, Apr 10, 2007
    #1
    1. Advertising

  2. On Apr 10, 2:37 pm, "psychomad" <> 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_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.
    Alexey Smirnov, Apr 10, 2007
    #2
    1. Advertising

  3. On Apr 10, 9:08 pm, "Alexey Smirnov" <> wrote:
    > On Apr 10, 2:37 pm, "psychomad" <> 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_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.- 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 & "' "
    Alexey Smirnov, Apr 10, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VDg=?=
    Replies:
    1
    Views:
    5,887
    Keith
    Nov 7, 2003
  2. NicK chlam via DotNetMonster.com
    Replies:
    0
    Views:
    4,857
    NicK chlam via DotNetMonster.com
    Mar 21, 2005
  3. DC
    Replies:
    1
    Views:
    1,116
  4. Bobby Edward
    Replies:
    1
    Views:
    4,463
    Kevin Spencer
    Mar 5, 2008
  5. Jack
    Replies:
    7
    Views:
    271
Loading...

Share This Page