C# Programming
12-25-2009, 08:10 AM
Hi,
I am using oledbconnection to get tablename(spreadsheet).This works well in my local system(Vista) but while deploying in server(Windows server 2008)it is not getting the tablename using OleDbSchemaGuid.Tables.What Might be wrong could anyone help
using (OleDbConnection con = ConnectionManager.GetExcelConnection(filename))
{
System.Data.DataTable dt = null;
dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (dt != null)
{
DataRow dr = dt.Rows[0];
excelSheetName = dr["TABLE_NAME"].ToString();
}
}
public static OleDbConnection GetExcelConnection(string filePath)
{
string connectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}; Extended Properties=""Excel 8.0;HDR=Yes;""", filePath);
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
return connection;
}
Thanks.
I am using oledbconnection to get tablename(spreadsheet).This works well in my local system(Vista) but while deploying in server(Windows server 2008)it is not getting the tablename using OleDbSchemaGuid.Tables.What Might be wrong could anyone help
using (OleDbConnection con = ConnectionManager.GetExcelConnection(filename))
{
System.Data.DataTable dt = null;
dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (dt != null)
{
DataRow dr = dt.Rows[0];
excelSheetName = dr["TABLE_NAME"].ToString();
}
}
public static OleDbConnection GetExcelConnection(string filePath)
{
string connectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}; Extended Properties=""Excel 8.0;HDR=Yes;""", filePath);
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
return connection;
}
Thanks.