Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: What's wrong with this code?


Message #1 by "Uma Maheswari" <maheswarim@r...> on 28 Feb 2001 12:18:45 -0000
hi,



Actually I tried to delete a row from a table(SQL)

using ADO.Net. 



This is the function I used:



public int deleterow(string username)

{

try

{

ADOConnection objconn 

new ADOConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=UserAccount;Data
Source=MUMA;");			

string strSQL = "select * from UserAccountTable";



ADODataSetCommand dsc = new ADODataSetCommand(strSQL,objconn);



DataSet ds = new DataSet();		

	

dsc.DeleteCommand = new ADOCommand("delete from UserAccountTable where username = '"+username.Trim()+"'",objconn);						

dsc.FillDataSet(ds,"UserAccountTable");

Console.WriteLine(ds.Tables["UserAccountTable"].Rows.Count);  



return(dsc.Update(ds,"UserAccountTable"));

}

catch(Exception e)

{

	Console.WriteLine(e.Message);	

}

return 0;		

}



The code doesnot throw any exceptions.

But the particular row is not deleted in the Database.

It remains unaffected.



What's wrong with this code?  Please correct me...



Thanks.



Regards,



Uma






  Return to Index