בעיית חיבור בין סי שארפ לבייס (האקסס של אופן אופיס) - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

בעיית חיבור בין סי שארפ לבייס (האקסס של אופן אופיס)


win4it

Recommended Posts

התקנתי על המחשב אופן וכעת אני מתקשה ליצור קוד שמוסיף לטבלה שורה

 

תודה רבה

 


     private void btnGo_Click(object sender, EventArgs e)
        {
            
            string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Public\\pro\\db.odb";

            OleDbConnection MyConn = new OleDbConnection(ConnStr);

            try
            {

                MyConn.Open();

                string mySelectQuery = "INSERT INTO tblNames (ID, strName) ";
                mySelectQuery = mySelectQuery + " VALUES (@ID, @strName) ";
                
                OleDbCommand insert_command = new OleDbCommand(mySelectQuery);
                
                insert_command.Parameters.AddWithValue("@strName", "20160229");
                insert_command.Parameters.AddWithValue("@ID", 10);
                
                insert_command.ExecuteNonQuery();

            }
            catch (Exception exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.ToString());
                try
                {
                    using (StreamWriter writer = new StreamWriter("C:\\Users\\Public\\pro\\bug.txt"))
                    {
                        writer.Write(exc.ToString());
                        writer.WriteLine(" ");
                        
                    }
                }//try

                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString());

                }
            }
            finally
            {
                MyConn.Close();
            }
        }

System.Data.OleDb.OleDbException (0x80004005): Unrecognized database format 'C:\Users\Public\pro\db.odb'.
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at try2.Form1.btnGo_Click(Object sender, EventArgs e) in 


 

קישור לתוכן
שתף באתרים אחרים

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...