-
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
Sandra
gonewild at muchomail.com
-
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.
-
Re: Sql vb
Sounds like you need to design your DB better. There should be a unique key to both tables
-
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.