Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I got error like this 'ODBC Call Failed ' while importing db from access to sql.

I have written code like this
C#


foreach (string tableName in tableNames)
{
//cn1 = new SqlConnection(con);
//if (cn1.State != ConnectionState.Open) { cn1.Open(); }
//SqlCommand cmd = new SqlCommand("select * into [" + tableName + "] from OPENROWSET('Microsoft.Jet.OLEDB.4.0','" + tr + "';'Admin';'',[" + tableName + "])");
//cmd.Connection = cn1;
//cmd.ExecuteNonQuery();
OleDbCommand cmd = new OleDbCommand("select * into [" + con + "].[" + tableName + "] FROM [" + tableName + "]", connection);
//OleDbCommand cmd = new OleDbCommand("select [[" + tableName + "].*] into [" + con + "].[" + tableName + "] From [" + tableName + "]");
cmd.Connection = connection;
cmd.ExecuteNonQuery();
connection.Close();
}

C#
select * into [ODBC;Driver=SQL Server;Data Source=serverpc\sqlexpress,52120;Initial Catalog=TARUN_DB;Persist Security Info=True;User ID=vipl-user;Password=vipl-user!@#$%;MultipleActiveResultSets=True].[ClientAc] FROM [ClientAc]

If any help to resolve this error would be much appreciated.
Posted
Updated 5-Oct-15 23:46pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900