andreasberglind
12-19-03, 06:15 AM
Iīm tryin to get a DeleteCommand for my DataGrid to work, but something is wrong. Can anyone help me? My Command looks like this:
private void lendingGrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string movietitle=e.Item.Cells[0].Text;
SqlConnection conn = new SqlConnection(strConnection);
//The SQL command is written on one line in the compiler, of course.
//Itīs also tested in Query Analyzer, and works fine.
SqlCommand command = new SqlCommand("declare @title_ID int
select title_ID = titleID from movietitle where title = '"+movietitle+"'
delete from lending where TitleID = @title_ID", conn);
conn.Open();
command.ExecuteNonQuery();
conn.Close();
//rebind data
getData();
}
My greatest problem is that the DeleteCommand doesnīt seem to run at all.
What else do i nee to do, besides this, and set the DeleteCommand property?
PLEASE HELP!!
/Andreas
private void lendingGrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string movietitle=e.Item.Cells[0].Text;
SqlConnection conn = new SqlConnection(strConnection);
//The SQL command is written on one line in the compiler, of course.
//Itīs also tested in Query Analyzer, and works fine.
SqlCommand command = new SqlCommand("declare @title_ID int
select title_ID = titleID from movietitle where title = '"+movietitle+"'
delete from lending where TitleID = @title_ID", conn);
conn.Open();
command.ExecuteNonQuery();
conn.Close();
//rebind data
getData();
}
My greatest problem is that the DeleteCommand doesnīt seem to run at all.
What else do i nee to do, besides this, and set the DeleteCommand property?
PLEASE HELP!!
/Andreas