Code Geting column name of Excel sheet to create sql table
HI all
This find the column name of excel sheet
so that we can create data base of same at run time........
{
string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mca23.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
OleDbConnection con = new OleDbConnection(excelConnectionString);
con.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", con);
OleDbDataReader rdr = cmd.ExecuteReader();
DataTable schema = rdr.GetSchemaTable();
foreach (DataRow row in schema.Rows)
{
int i = 0;
foreach (DataColumn col in schema.Columns)
{ //
if (i == 0)
{
Response.Write(row[0]);
}
i = i + 1;
}
}
rdr.Close();
}

thaxs for the code
it is good
keep posting