Yesterday modified a tool, the computer is running normally after compiling, but put on the server to execute but not, prompt:
Message:getoledbschematable requires an open and available Connection. The connection ' s closed
Recheck the office-related DLL files, and switch to a server with offie installed.
Check the code carefully, and found that the original segment of the exception to capture the mask off (red part):
using(OleDbConnection oc =NewOleDbConnection (strconn)) { if(OC. state = =connectionstate.closed) {Try{oc. Open (); } catch (Exception ex) { string ss = Ex. Message; } } DataTable schematable= OC. GetOleDbSchemaTable (System.Data.OleDb.OleDbSchemaGuid.Tables,NULL); stringTableName = schematable.rows[0][2]. ToString (). Trim (); stringstrSQL ="Select * FROM ["+ TableName +"]"; OleDbDataAdapter ODA=NewOleDbDataAdapter (strSQL, OC); Oda. Fill (DS); Oda. Dispose (); Oc. Close (); } returnDs. tables[0];
Pit Daddy. Find the final error message: Oledbconnection.open () prompt: Not registered on the local computer "microsoft.jet.oledb.4.0
Baidu after the final solution is: at compile time to change the target CPU to x86, all OK. The reason is that when editing the default target CPU is arbitrary, but when running on a 64-bit system, it tries to use a 64-bit driver, but the system does not provide a 64-bit driver.
The middle go a lot of detours, search getoledbschematable requires an open and available Connection problem find solution not many, tried a few are white waste strength. The result is other problems.
Lessons learned: Be sure to locate the most fundamental problem, and then find a solution