deleting from a gridview with check boxes

  • Thread starter Thread starter JJ297
  • Start date Start date
J

JJ297

I have a button on the other page that right now deletes from one
table

How do I set up this part of the code to delete from another table
called resources or a stored procedure I have called DeleteResource?

Dim cn As Data.SqlClient.SqlConnection = New
Data.SqlClient.SqlConnection(SqlDataSource1.ConnectionString)
If chkBox Then
Try
Dim deleteSQL As String = _
"DELETE from Titles WHERE TitleID IN (" + _
gvIDs.Substring(0, gvIDs.LastIndexOf(",")) + ")"
Dim cmd As Data.SqlClient.SqlCommand = New
Data.SqlClient.SqlCommand(deleteSQL, cn)
cn.Open()
cmd.ExecuteNonQuery()
GridView1.DataBind()
Catch Err As Data.SqlClient.SqlException
Response.Write(Err.Message.ToString)
Finally
cn.Close()
End Try
 
I have a button on the other page that right now deletes from one
table

How do I set up this part of the code to delete from another table
called resources or a stored procedure I have called DeleteResource?

Dim cn As Data.SqlClient.SqlConnection = New
Data.SqlClient.SqlConnection(SqlDataSource1.ConnectionString)
If chkBox Then
Try
Dim deleteSQL As String = _
"DELETE from Titles WHERE TitleID IN (" + _
gvIDs.Substring(0, gvIDs.LastIndexOf(",")) + ")"
Dim cmd As Data.SqlClient.SqlCommand = New
Data.SqlClient.SqlCommand(deleteSQL, cn)
cn.Open()
cmd.ExecuteNonQuery()
GridView1.DataBind()
Catch Err As Data.SqlClient.SqlException
Response.Write(Err.Message.ToString)
Finally
cn.Close()
End Try

Figured it out I checked the box to cascade deleted related records
 
Back
Top