Click here to Skip to main content
15,885,948 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got an error like this 'Could not find installable ISAM.'

while copying access db to sql db

My code is

C#
try
          {
              cn1 = new SqlConnection(con);
              if (cn1.State != ConnectionState.Open) { cn1.Open(); }
              cmd1 = new SqlCommand("Create database " + db + "");
              cmd1.Connection = cn1;
              cmd1.ExecuteNonQuery();
              con += ";Driver=SQL Server;database='" + db + "'";
          }
          catch (Exception Ex) { }
          try
          {
              DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
              DataTable userTables = null;
              using (connection)
              {
                  string mappath = dataGridView1.CurrentRow.Cells["Path"].Value.ToString();
                  string[] filePaths = Directory.GetFiles(@"" + mappath + "", "*.mdb", SearchOption.TopDirectoryOnly);
                  // c:\test\test.mdb
                  foreach (string tr in filePaths)
                  {
                      connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + tr + "";
                      string[] restrictions = new string[4];
                      restrictions[3] = "Table";
                      connection.Open();
                      userTables = connection.GetSchema("Tables", restrictions);
                      List<string> tableNames = new List<string>();
                      for (int i = 0; i &lt; userTables.Rows.Count; i++)
                          tableNames.Add(userTables.Rows[i][2].ToString());
                      try
                      {
                          foreach (string tableName in tableNames)
                          {
                              OleDbCommand cmd = new OleDbCommand("select * into ["+con+"].["+tableName+"] from [" + tableName + "]");      // Got error Here
                              cmd.Connection = connection;
                              cmd.ExecuteNonQuery();
                          }
                      }
                      catch (Exception Ex) { connection.Close(); }
                      connection.Close();
                  }
              }
          }
          catch (Exception Ex) { }


Can u pls resolve it
Posted
Updated 5-Aug-15 2:06am
v2

1 solution

There are quite a few reasons for that error message. Check the following:
- you're compiling 32 bit application, not 64.
- since you loop through the locations check that the names of the folders are valid, especially if this works for some folders.
 
Share this answer
 
Comments
TarunKumarSusarapu 29-Jul-15 3:11am    
This is my query
select * into [Data Source='serverpc\sqlexpress';Persist Security Info=True;User ID= 'vipl-user';Password='vipl-user!@#$%';Provider=SQLOLEDB.1;Initial Catalog=TTT].[ClientAc] from [ClientAc]
while executing I got error
Wendelius 29-Jul-15 3:44am    
If I understand the situation correctly: Instead of selecting at Access side do this vice versa. Execute the insert statement in the SQL Server, something like

INSERT INTO TableName SELECT FROM [oledb connection string to access]
TarunKumarSusarapu 29-Jul-15 4:54am    
I tried that
select * into ClientAc from [Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\ezacc\DATA\accountdata.mdb].[ClientAc]
I got error like this

Invalid object name 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\ezacc\DATA\accountdata.mdb.ClientAc'.
TarunKumarSusarapu 29-Jul-15 5:25am    
OleDbCommand cmd = new OleDbCommand("select * into ["+con+"].["+tableName+"] from [" + tableName + "]");
cmd.Connection = connection;
cmd.ExecuteNonQuery();


I got Invalid Argument error
Wendelius 29-Jul-15 5:32am    
You need to use OPENROWSET (or similar commands). Have a look at OPENROWSET (Transact-SQL)[^]

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