J
JJ297
I created a stored procedure to delete the titleID and then insert the
same titleID but also add several classificationIDs that I select from
several check boxes. Here's the stored procedure.
CREATE procedure UpdateTopicsNTitles
@titleID int,
@classificationID int
AS
Begin
delete from titleclassification
where titleID=@titleid
insert into titleclassification
(TitleID, classificationID)
values (@Titleid, @classificationID )
end
GO
I'm having problems coding my button click. I want it to first delete
the titleID from the database then insert the same titleID that's
selected and all of the items checked for the classificationID.
This is what I've tried doing. Can someone tell me what I've done
wrong as it only adds the title and one classificationID.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TrainUserConnectionString").ConnectionString)
Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "UpdateTopicsNTitles"
.Parameters.AddWithValue("@TitleID", DropDownList1.Text)
.Parameters.AddWithValue("@classificationID",
CheckBoxList1.Text)
End With
Try
conn.Open()
cmd.ExecuteNonQuery() 'executes the sql that I assign.
don't need anything back from db
CheckBoxList1.DataBind()
Catch ex As Data.SqlClient.SqlException
Throw New ApplicationException("An error occurred while
trying to insert the record")
Finally
conn.Dispose()
End Try
same titleID but also add several classificationIDs that I select from
several check boxes. Here's the stored procedure.
CREATE procedure UpdateTopicsNTitles
@titleID int,
@classificationID int
AS
Begin
delete from titleclassification
where titleID=@titleid
insert into titleclassification
(TitleID, classificationID)
values (@Titleid, @classificationID )
end
GO
I'm having problems coding my button click. I want it to first delete
the titleID from the database then insert the same titleID that's
selected and all of the items checked for the classificationID.
This is what I've tried doing. Can someone tell me what I've done
wrong as it only adds the title and one classificationID.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TrainUserConnectionString").ConnectionString)
Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "UpdateTopicsNTitles"
.Parameters.AddWithValue("@TitleID", DropDownList1.Text)
.Parameters.AddWithValue("@classificationID",
CheckBoxList1.Text)
End With
Try
conn.Open()
cmd.ExecuteNonQuery() 'executes the sql that I assign.
don't need anything back from db
CheckBoxList1.DataBind()
Catch ex As Data.SqlClient.SqlException
Throw New ApplicationException("An error occurred while
trying to insert the record")
Finally
conn.Dispose()
End Try