CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    195

    Exclamation error executereader

    Dim objConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="path")
    objConnection.Open()

    rndnum = rnd(99999999)
    sql1 = "SELECT OrderID FROM Orders WHERE Orders.OrderID = '" & rndnum & " ' "
    Dim MyCommand As New OleDb.OleDbCommand(sql1, objConnection)
    MyReader = MyCommand.ExecuteReader
    MyReader.Read()

    The above is the code . When i ran my app i got the foll error



    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 108: sql1 = "SELECT OrderID FROM Orders WHERE Orders.OrderID = '" & rndnum & " ' "
    Line 109: Dim MyCommand As New OleDb.OleDbCommand(sql1, objConnection)
    Line 110: MyReader = MyCommand.ExecuteReader
    Line 111: MyReader.Read()


    Please throw some ideas guys.thnx

  2. #2
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: error executereader

    What is the type of OrderId? If it is a number then the problem is the use of ' .
    Code:
    sql1 = "SELECT OrderID FROM Orders WHERE Orders.OrderID = '" & rndnum & " ' "
    Try this:
    Code:
    sql1 = "SELECT OrderID FROM Orders WHERE Orders.OrderID = " & rndnum
    The use of ' is for strings.

  3. #3
    Join Date
    Jan 2003
    Posts
    195

    Re: error executereader

    Thnx for the pointer. solved that problem

    but the current error message is as follows

    There is already an open DataReader associated with this Connection which must be closed first.
    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.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.

    Source Error:


    Line 111: sql1 = "SELECT OrderID FROM Orders WHERE Orders.OrderID = " & rndnum & " "
    Line 112: Dim dbCommand As New OleDb.OleDbCommand(sql1, dbConnection)
    Line 113: dbReader = dbCommand.ExecuteReader
    Line 114: dbReader.Read()


    Error at line 113

    plz help to resolve this. thnx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured