Recently, to help a friend to do a small software, need to use the database and Excel read and write operations, about the database crud will not say, Just say one thing: XP and Win7 for Environment.currentdirectoty recognition incredibly inconsistent, resulting in the use of OpenDialog, the database is often not found.
Excel read and write operations, related to the lower left corner of the Excel table name recognition problem, some "Sheet1", some "worksheet 1", this problem can be solved using the following methods:
OleDbConnection oleconn = new OleDbConnection (strconn); Oleconn.open (); DataTable schematable = oleconn.getoledbschematable (OleDbSchemaGuid.Tables, new object[] {null, NULL, NULL, "TABLE"}); c4/>string strtablename = schematable.rows[0]["table_name"]. ToString (). Trim ();
Be sure to Oleconn.open () first, then check the name of the table, or there will be a crash phenomenon.
C # Windows Client Development Pit