ADO/ADO.NET - No such interface supported

Asked By Bhanuprakash T.R on 21-Jun-12 01:25 AM
Earn up to 20 extra points for answering this tough question.
Hello sir i placed one  button(Writedb) click means . what are the data in sdf file . whole data inserted into access sheet. it is also working fine. the file was stored in the path C:/StockManagement/StockManagement.mdb. if i compile first time means it was created successfully. if again compile means it shows an runtime error is database already exist. now i want solution was if the database is already is there means delete the database and created new one.if the database is not there created new one..please tell me the solution
i try this code
//button click
if (File.Exists(@"C:/StockManagement/StockManagement.mdb"))
      {
}
else{

    MessageBox.Show("file was trying to create");
          Directory.CreateDirectory("C:/StockManagement");
          ADOX.CatalogClass cat = new ADOX.CatalogClass();
          string createStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/StockManagement/StockManagement.mdb;";
          cat.Create(createStr);
      MessageBox.Show("database created successfully");
      cat = null;
      MessageBox.Show(pra);
      SqlCeConnection con = new SqlCeConnection("Data Source=" + pra + "");
      SqlCeDataAdapter da = new SqlCeDataAdapter("select * from purchaseOrder", con);
      DataTable dt = new DataTable();
      da.Fill(dt);
      OleDbConnection con1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/StockManagement/StockManagement.mdb");
      con1.Open();
      OleDbCommand cmd = con1.CreateCommand();
      cmd.CommandText = "create table purchaseOrder(barcode varchar(150),Actualqty varchar(150),LocationID varchar(100))";
      cmd.ExecuteNonQuery();


      for (int i = 0; i < dt.Rows.Count; i++)
      {
        cmd.CommandText = "insert into purchaseOrder (barcode,Actualqty,LocationID) values('" + dt.Rows[i]["barcode"].ToString() + "','" + dt.Rows[i]["Actualqty"].ToString() + "','" + dt.Rows[i]["LocationID"].ToString() + "')";


        cmd.ExecuteNonQuery();

      }

}

i get run time error as No such interface supported in this line cat.Create(createStr); please tell me how to solve the problem
Vikram Singh Saini replied to Bhanuprakash T.R on 21-Jun-12 09:53 PM
Replace following code line:

ADOX.CatalogClass cat = new ADOX.CatalogClass();
      string createStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/StockManagement/StockManagement.mdb;";
      cat.Create(createStr);


by the following code:

ADOX.Catalog cat = new ADOX.Catalog();

string createStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/StockManagement/StockManagement.mdb;";

cat.Create(createStr);

 
Note: The first line of modified code is important. We have modified the code line with interface type by removing suffix 'Class'. (More details on same at http://blogs.msdn.com/b/mshneer/archive/2009/12/07/interop-type-xxx-cannot-be-embedded-use-the-applicable-interface-instead.aspx)


I tested the code and it worked fine. Do response back if it helped or not.
help
tell me the solution i try this code / / button click Directory.CreateDirectory("C: / StockManagement"); ADOX.CatalogClass cat = new ADOX.CatalogClass(); cat.Create("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = C: / StockManagement / StockManagement.mdb;" + "Jet Type = 5"); MessageBox.Show("database created successfully"); cat = null; if(cat.ex) MessageBox.Show(pra); SqlCeConnection con = new SqlCeConnection("Data Source = " + textbox1.text.toString + ""); SqlCeDataAdapter da = new SqlCeDataAdapter("select * from purchaseOrder", con); DataTable dt = new DataTable(); da.Fill(dt); OleDbConnection con1 = new OleDbConnection StockManagement.mdb")) { } else{ MessageBox.Show("file was trying to create"); Directory.CreateDirectory("C: / StockManagement"); ADOX.CatalogClass cat = new ADOX.CatalogClass(); cat.Create("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = C: / StockManagement / StockManagement.mdb;" + "Jet
data or else update new data into same mdb file. Directory.CreateDirectory("C: / StockManagement"); ADOX.CatalogClass cat = new ADOX.CatalogClass(); cat.Create("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = C: / StockManagement / StockManagement.mdb;" + "Jet OLEDB:Engine Type = 5"); MessageBox.Show("database created successfully"); cat = null; MessageBox.Show(pra); SqlCeConnection con = new SqlCeConnection("Data Source = " + textbox1.toString + ""); SqlCeDataAdapter da = new SqlCeDataAdapter("select * from purchaseOrder", con); DataTable dt = new DataTable(); da.Fill(dt); OleDbConnection con1 = new OleDbConnection the if and else condition Thanks Bhanuprakash Check this code- Directory.CreateDirectory("C: / StockManagement"); ADOX.CatalogClass cat = new ADOX.CatalogClass(); cat.Create("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = C: / StockManagement / StockManagement.mdb; " + "Jet
if else condition please tell me i try this code Directory.CreateDirectory("C: / StockManagement"); ADOX.CatalogClass cat = new ADOX.CatalogClass(); cat.Create("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = C: / StockManagement / StockManagement.mdb;" + "Jet OLEDB:Engine Type = 5"); MessageBox.Show("database created successfully"); cat = null; MessageBox.Show(pra); SqlCeConnection con = new SqlCeConnection("Data Source = " + textbox1.text.toString+ ""); SqlCeDataAdapter da = new SqlCeDataAdapter("select * from purchaseOrder", con); DataTable dt = new DataTable(); da.Fill(dt); OleDbConnection con1 = new OleDbConnection
ADOX.CatalogClass odxc = new ADOX.CatalogClass() ; System.Data.OleDb.OleDbConnection Omaincon = new System.Data.OleDb.OleDbConnection(); Omaincon.ConnectionString = "Provider = Microsoft.Jet in link http: / / support.microsoft.com / kb / 317881 / EN-US / keywords: OleDbConnection, Data Source description: Catalogclass ADOX.CatalogClass odxc = new ADOX.CatalogClass() ; System.Data.OleDb.OleDbConnection Omaincon = new System.Data.OleDb.OleDbCo
worksheet stores 3 tables i try this following code / / button click { filename = textBox1.Text.ToString(); SqlCeConnection con = new SqlCeConnection("DataSource = " + filename + ""); SqlCeDataAdapter da = new SqlCeDataAdapter("select * from stockTake", con); SqlCeDataAdapter da1 = new SqlCeDataAdapter("select * from purchaseOrder", con); SqlCeDataAdapter da2 = new SqlCeDataAdapter("select * from newstock", con); DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); DataTable dt2 = new
Hello, I observe a strange behaviour of SqlCeConnection disposing. I have a simple class to connect to DB with one static SqlCeConnection namespace SOMETHING { / / / <summary> / / / This singleton class holds the common application values. / / / < / summary> sealed class Common static readonly Common Values = new Common(); private Common() { Load(); } public void Load() { this.databaseConnection = new SqlCeConnection(LocalConnectionString); } public void DbOpen() { if (this.databaseConnection.State ! = ConnectionState.Open) this.databaseConnection.Open(); } #region Properties private SqlCeConnection databaseConnection; public SqlCeConnection DatabaseConnection { get { return databaseConnection; } set { databaseConnection = value; } } public string LocalConnectionString { get { return "Data Source = " + localDbPath Hart Visual Developer - Device Application Development MVP http: / / simonrhart.blogspot.com keywords: Strange(?), behaviour, of, SqlCeConnection description: Hello, I observe a strange behaviour of SqlCeConnection disposing. I have a simple class to connect to DB with one static SqlCeConnection namespace
Hy all, this is my code (quite simple. . .): using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { using (SqlCeCommand command = new SqlCeCommand(Query, connection)) { connection.Open(); reader = command.ExecuteReader(); } } If I CommandType.Text . . cod Hy cod, thank you for your answer. Now the code is: using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { using (SqlCeCommand command = new SqlCeCommand(Query, connection)) { command.CommandType = System.Data.CommandType.Text; connection Application Development MVP keywords: SqlCeDataReader description: Hy all, this is my code (quite simple. . .): using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { using (SqlCeCommand command =
Hy all, look at this code: string connectionString = "Data Source = D: \ Visual Studio 2005 \ Projects \ myProject \ myProject \ myProject.sdf;Persist Security Info = False;"; Using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { using (SqlCeCommand comando = connection.CreateCommand()) { connection.Open(); / / <- ERROR! } } System alwais throws an exception saying that's why you receive the error message. - - Ginny Caughey Device Application Development MVP keywords: SqlCeConnection description: Hy all, look at this code: string connectionString = Data Source = D: \ Visual Studio 2005
sqlceme30.dll' SQL Server 28-Oct-12 07:29 PM While Opening the SqlCe Connection ( SqlCeConnection sqlCon = new SqlCeConnection(); ) i'm getting this error Unable to load DLL 'sqlceme30.dll': The specified could not aspx?id = 17876 description: Unable to load DLL 'sqlceme30.dll' While Opening the SqlCe Connection (SqlCeConnection sqlCon = new SqlCeConnection();) i'm getting this error Unable t