How to delete data from MS Excel Workbook database
Hi Friends,
How are you all? Hope you are doing well. Right now I am doing a project in ASP.NET with C#.
I have successfully inserted, selected data from ASP.NET to Microsoft Excel Workbook database.
But how to delete data from Microsoft Excel Workbook database in ASP.NET.
The insert code of âMS Excel Workbookâ database in ASP.NET is given below.
SqlDataReader aReader ;
aReader = objCmd.ExecuteReader();
//---------------EXCEL CONNECTION -----------------------
String source;
OleDbConnection con;
OleDbCommand cmd;
source = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + @"C:\swa.xls;" +
"Extended Properties=Excel 8.0;";
con = new OleDbConnection (source);
con.Open();
//Add two records to the table named 'MyTable'.
cmd = new OleDbCommand(source,con);
while(aReader.Read())
{
string cmdText="";
cmdText = "Insert into [Sheet1$] "+
"([Nam ID], [Nom ID])values(" +
"'"+ aReader["Nam ID"].ToString()+"',"+
"'"+ aReader["Nom ID"].ToString() +"')";
cmd.CommandText = cmdText;
text1.Text = cmdText;
cmd.ExecuteNonQuery();
Hope you all understand the problem.
Thanks,
Regards,
Swadhin.
|