Hey guys
Im still busy with a webapp and the only thing that I still need to do is to be able to delete a record in other words a (row) from my datbase..
I am able to create a new row now all through my webapplication (website) but now I need to be able to delete the record that is in the textboxes..
my dataset fills a couple of textboxes so what you see on the textboxes is the current rows data, so I made a Button called Delete Record, Which I want to use to delete the records thats showing in the textboxes now...
Ive made a hidden field, so my rows got a unique number id, and then I made the hidden field = to the unique Id..
hidCode.Value = _ds.Tables[0].Rows[indexer]["AuditNameCode"].ToString();
here is my code :
CODE
protected void ButtonDelete_Click(object sender, EventArgs e)
{
SqlConnection _MyCon = new SqlConnection("Server=SECDW;database=SPAudit;uid=adffd;pwd=dfdfv;Connection Timeout=120;pooling=false");
SqlCommand command = new SqlCommand("DELETE FROM MainDetail WHERE AuditNameCode = " + hidCode.Value , _MyCon);
command.CommandType = CommandType.Text;
_MyCon.Open();
command.ExecuteNonQuery();
_MyCon.Close();
}
Please can someone give me some help, its not working:)
Thanx
Please use code tags for posting code, like so =>
This post has been edited by PsychoCoder: 15 Nov, 2007 - 05:25 AM