Monday, May 24, 2010

Error deleting record on Excel using C# code, under Microsoft Expression Web. Please Help. Here is my code:?

When I view my web page there's no error that prompts and I can even click my delete button, but when I open my Excel sheet the data is still there. I need your suggestion.





public void delete_Click(Object Src, EventArgs E)


{


string connectionString;





connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +


@"Data Source=C:\Documents and Settings\ojt04\My Documents\mySit\payroll\database\profile... +


"Extended Properties=Excel 8.0;";


OleDbConnection connA = new OleDbConnection(connectionString);


connA.Open();


OleDbCommand command1 = new OleDbCommand("DELETE FROM [profilesheet$](FirstName) WHERE IDNo=txtid.Text",connA);


connA.Close();


txtid.Text="";


txtfname.Text="";


txtlname.Text="";


txtmname.Text="";


txtadd.Text="";


txtbday.Text="";


txtcontact.Text="";


txtposition.Text="";


txtdept.Text="";





}

Error deleting record on Excel using C# code, under Microsoft Expression Web. Please Help. Here is my code:?
This isn't right:


"DELETE FROM [profilesheet$](FirstName) WHERE IDNo=txtid.Text"





It should be


"DELETE FROM [profilesheet$](FirstName) WHERE IDNo=" + txtid.Text





That was the first problem I saw anyway.
Reply:Are you deleting each cell at a time ??? that's the only you can change a excel spreadsheet


No comments:

Post a Comment