CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: Sql vb

  1. #1
    Join Date
    Mar 2010

    Sql vb

    I have two databases in sql 2005
    there is one table in each database called tbl200
    this table has 2 fields called invoice no ,and supplier no
    when the user enters an invoice in any of the two tables through a vb form I want the system to check whether this invoice number for this supplier already exists in any of the two databases or not.

    How can I achieve that ?

    Many thanks

    gonewild at

  2. #2
    Join Date
    Jul 2006

    Re: Sql vb

    Using ADO you would open two connections to each of the databases.
    Next you would open a Recordset with a query string of like "where invoice_number = xxx" from one connection.
    Next you open a similar Recordset from the second connection.
    The apropriate invoice number exists if the Recordset opened is not at EoF.

    I think this is an abstract description as close as possible to your abstract description of the solution you are searching for.

  3. #3
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Sql vb

    Sounds like you need to design your DB better. There should be a unique key to both tables

    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!

  4. #4
    Join Date
    Feb 2008

    Re: Sql vb

    In your code you should have one connection each to the databases. Either you can use the method given by Wof or you can open two different recordset for each database and use
    RS.Find method to find a specific record. If record doesnot exist Rs.eof will be true otherwise false, with above hints you can build your own logic and apply to your code.
    Encourage the efforts of fellow members by rating

    Lets not Spoon Feed and create pool of lazy programmers

    - ComIT Solutions

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)