I got error like this 'Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ClientAc901". OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ClientAc901" returned message "The Microsoft Office Access database engine cannot open or write to the file '\\Pc09\data3\accountdata.mdb'. It is already opened exclusively by another user, or you need permission to view and write its data.".' while importing msaccess data to sql.
void copytable() { try { cmd = new SqlCommand("SP_Create"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@servername", acc); cmd.Parameters.AddWithValue("@datasr", path); cmd.Parameters.AddWithValue("@table", sourcetable); cmd.Parameters.AddWithValue("@table1", desttable); cmd.Parameters.AddWithValue("@db", db); cmd.CommandTimeout = 180; cmd.Connection = cn1; connection.Close(); string state = connection.State.ToString(); if (cn1.State != ConnectionState.Open) { cn1.Open(); } cmd.ExecuteNonQuery(); cn1.Close(); } catch (Exception exc) { connection.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)