Link to home
Start Free TrialLog in
Avatar of Choklander
Choklander

asked on

MS Access SELECT INTO

I have two databases. Lets call the first DB1 and the second DB2.

I am connecting to those databases in MFC.

I am trying to copy one table from DB2 to DB1. Lets call it Table1. Lets call the new table Table2.

I use ExecuteSQL() function of CDatabase calling it from the first Database object.

m_db1.ExecuteSQL(_T(SELECT * INTO Table2 FROM Table1 IN 'Data\\DB2.mdb'));

Well everything is working perfectly. But I am going to put passwords on those two databases. My question is: How do I provide the passwords in the SQLString?
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

You should be able to open a connection to the database using the password, then execute your SQL and close the connection.

/gustav
Avatar of Choklander
Choklander

ASKER

Well how do I provide their passwords ? I open db1 and from it's object I call the ExeciteSQL. But in that SQLString I need to provide the password for db2. How do I provide it? Can you show me on the SQLString I have provided you with?
ASKER CERTIFIED SOLUTION
Avatar of datAdrenaline
datAdrenaline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> I need to provide the password for db2. How do I provide it?

By opening a connection til db2 too including the password.

I know nothing about MFC so I cannot provide code but this method is generic.

/gustav
Hello Cactus ...

The posters question indicates that the desire is to have the pwd (assuming its a database password) in the SQL statement ...

>> How do I provide the passwords in the SQLString? <<
Thanks a lot. The problem with my string was that I put my database source in the '' single quotes. Nice explanation top grade. Have fun.
You're most welcome! ...