CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2005
    Location
    SouthEastern, PA
    Posts
    67

    Error on Select using ADO

    The following is an extract from a VB6 application I am writing:
    Code:
    Dim MyConn As ADODB.Connection
    Dim MyRecSet As ADODB.Recordset
    Set MyConn = New ADODB.Connection
    MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\Data\Orion-Testing\TestServer\Inventory.mdb"
    MyConn.Open
     
    Set MyRecSet = MyConn.Execute("Select * from GenericToAlt where dbAltPN = '" & cboAltPart.Text & "'")
    If MyRecSet.RecordCount = 0 Then
    Stop
    End If
    I am getting the error: "No value given for one or more required parameters.". It is happening on the "Set MyRecSet ..." statement.

    As I step the code, the value of cboAltPart.Text is correct.

    Here is the layout of the Table:
    TableName: GenericToAlt
    dbAtlPN text 30
    dbAltPO text 10

    There are NO primary or secondary indexes.
    I can NOT find the problem. Can YOU help?
    Sam

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Error on Select using ADO

    If you are returning a RS, then use OPEN

    Code:
    MyConn.Open
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2005
    Location
    Delhi, INDIA
    Posts
    237

    Thumbs up Re: Error on Select using ADO

    Dear friend pepsisc,

    use your query in the following format, and it will works..100%!

    Code:
    Dim MyConn As ADODB.Connection
    Dim MyRecSet As ADODB.Recordset
    Set MyConn = New ADODB.Connection
    MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\Data\Orion-Testing\TestServer\Inventory.mdb"
    MyConn.Open
     
    Set MyRecSet = MyConn.Execute("SELECT GenericToAlt.dbAtlPN, GenericToAlt.dbAltPO
    FROM GenericToAlt where GenericToAlt.dbAltPN = '" & cboAltPart.Text & "'")
    If MyRecSet.RecordCount = 0 Then
    Stop
    End If;
    Enjoy !
    Quote Originally Posted by pepsisc
    The following is an extract from a VB6 application I am writing:
    Code:
    Dim MyConn As ADODB.Connection
    Dim MyRecSet As ADODB.Recordset
    Set MyConn = New ADODB.Connection
    MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\Data\Orion-Testing\TestServer\Inventory.mdb"
    MyConn.Open
     
    Set MyRecSet = MyConn.Execute("Select * from GenericToAlt where dbAltPN = '" & cboAltPart.Text & "'")
    If MyRecSet.RecordCount = 0 Then
    Stop
    End If
    I am getting the error: "No value given for one or more required parameters.". It is happening on the "Set MyRecSet ..." statement.

    As I step the code, the value of cboAltPart.Text is correct.

    Here is the layout of the Table:
    TableName: GenericToAlt
    dbAtlPN text 30
    dbAltPO text 10

    There are NO primary or secondary indexes.
    I can NOT find the problem. Can YOU help?
    I'M BACK AGAIN !!
    -------------------------------------------------------------------------
    enjoy the VB !
    If any post helps you, please rate that.
    Always try to findout the Solutions, instead just discussing the problem and its scope!

  4. #4
    Join Date
    Sep 2006
    Posts
    635

    Re: Error on Select using ADO

    Quote Originally Posted by pepsisc
    Code:
    If MyRecSet.RecordCount = 0 Then
    firstly it's posible that MyRecSet.RecordCount returns -1 to use Exceute stament.

    Quote Originally Posted by pepsisc
    As I step the code, the value of cboAltPart.Text is correct.
    what value cboAltPart.Text takes?

  5. #5
    Join Date
    Sep 2005
    Location
    Delhi, INDIA
    Posts
    237

    Re: Error on Select using ADO

    it will be a Textual value , as the ' prefixed and postfixed to it in the query !
    I'M BACK AGAIN !!
    -------------------------------------------------------------------------
    enjoy the VB !
    If any post helps you, please rate that.
    Always try to findout the Solutions, instead just discussing the problem and its scope!

  6. #6
    Join Date
    Dec 2006
    Location
    Pune, India.
    Posts
    579

    Re: Error on Select using ADO

    cboAltPart.Text must be empty.

    Try to run query with some hard coded string.

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