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!

Syncing a table between 2 access DB files

Status
Not open for further replies.

patrickstrijdonck

Programmer
Jan 18, 2009
97
NL
Hello,

Im trying to setup a one way sync between 2 different MS ACCESS files.

The first SQL query runs fine, If I add a record, it gets deleted.

The problem occurs at the second SQL query.
the error is: Invalid Argument.
Code:
selectSQLL = "INSERT INTO table1 SELECT * FROM [MS Access;DATABASE=" + Properties.Settings.Default.ConnectionString1 + ";].[table1]";

Code:
            //Delete all information from Stores Table.
            string selectSQLL1;
            string cmdstrr1 = Properties.Settings.Default.IT4STOCKConnectionString;

            selectSQLL1 = "DELETE * FROM table1";
            OleDbConnection conn1 = new OleDbConnection(cmdstrr1);
            OleDbCommand comn1 = new OleDbCommand(selectSQLL1, conn1);
            conn1.Open();
            comn1.ExecuteScalar();
            conn1.Close();
            
            //Copy all Data from Stores and put it into database
            string selectSQLL;
            string cmdstrr = Properties.Settings.Default.IT4STOCKConnectionString;

            selectSQLL = "INSERT INTO table1 SELECT * FROM [MS Access;DATABASE=" + Properties.Settings.Default.ConnectionString1 + ";].[table1]";
            OleDbConnection conn = new OleDbConnection(cmdstrr);
            OleDbCommand comn = new OleDbCommand(selectSQLL, conn);
            conn.Open();
            comn.ExecuteReader();
            
            conn.Close();

Am I missing something? Please help.
 
Got it,

Code:
Properties.Settings.Default.ConnectionString1

Was not correct, It had \10.0.0.1 instead of \\10.0.0.1

Thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top