创建了ODBC数据源后,怎样连接数据库?

来源:百度知道 编辑:UC知道 时间:2024/06/18 13:12:31
创建了ODBC数据源后,怎样连接数据库?

string str =addColumnName==true? @"Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + excelFilePath + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1;'":
@"Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + excelFilePath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;'";
OleDbConnection mConn = new OleDbConnection(str);
mConn.Open();
DataTable dt = mConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] {null, null, sheetName });

excelFilePath + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1;'":
@"Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + excelFilePath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;'";
OleDbConnection mConn = new OleDbConnection(str);
mConn.Open();
DataTable dt = mConn.GetOleDbSchemaTable(OleDbSchemaGuid.C