Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO -> problem with copying data

Status
Not open for further replies.

mischmasch

Programmer
May 10, 2011
11
Hi,

I have problem with copying data between two MS Access databases.

I have:
a) DataBase1 that has Table1 that has field Model
b) DataBase2 that has Table2 that has field Model

Both databases are protected. Password is: <>something[]

I try to copy data by using ADOCommand, so I have something like this:

with ADOCommand1 do
begin
Close;
ConnectionString := ... connection_string_to_DataBase1;

CommandText := 'INSERT INTO [Table1] SELECT Model FROM [;DATABASE=' + path_to_DataBase2 + ';PWD=<>something[]].[Table2];';

Execute;
Close;​
end;

When I try execute this, I get some error with message: wrong defined parameter ...

Anyone knows what I'm doing wrong?
Thx for help.



 
Hi mishmash,

the correct syntax would be:

Code:
 var SQL : String;
 ... 

 SQL := 'INSERT INTO [Table1] SELECT * FROM [MS Access;DATABASE=%s;Jet OLEDB:Database Password=%s;].[Table2]';
 CommandText := Format(SQL, [Database_Path, DatabasePassword]);
 ...

if this still doesn't work, then it might be that the square brackets in the password are giving problems.
so try to change the db password to not include square brackets and see if that helps...

/Daddy


-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks.
I will remove brackets, it will be the best options :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top