Add and Delete function can perform together at the same time?
Hi, guys
Do you know add and delete function can perform together at the same time?
Below are my code:
Code:
'Peform the delete function
Dim strSql1 As String
If SqlConnection.State <> ConnectionState.Open Then
SqlConnection.Open()
End If
strSql1 = "DELETE FROM COURSE_STRUCTURE where Crs_ID='" & DropLstCrs.SelectedValue & "' " & _
" and Crs_Year='" & DropLstCrsYear.SelectedValue & "' " & _
" and Crs_Semester='" & DropLstCrsSem.SelectedValue & "' ; Select * from COURSE_STRUCTURE "
Dim command1 As SqlCommand = New SqlCommand(strSql1, SqlConnection)
command1.ExecuteNonQuery()
SqlConnection.Close()
DACrsStructure.SelectCommand = command1
DsEduMgnt.COURSE_STRUCTURE.Clear()
Session.Item("DACrsStructure") = DACrsStructure
DACrsStructure.Fill(DsEduMgnt.COURSE_STRUCTURE)
'--------------------------------------------------------------
'Peform the add function
Dim i As Integer
Dim strSql2 As String
If SqlConnection.State <> ConnectionState.Open Then
SqlConnection.Open()
End If
For i = 0 To lstSelSub.Items.Count - 1
strSql2 = "INSERT INTO COURSE_STRUCTURE VALUES ( @CrsYear,@CrsSem,@CrsID,@SubjID);"
Dim command2 As SqlCommand = New SqlCommand(strSql2, SqlConnection)
With command2.Parameters
.Add(New SqlParameter("@CrsYear", CInt(DropLstCrsYear.SelectedValue)))
.Add(New SqlParameter("@CrsSem", CInt(DropLstCrsSem.SelectedValue)))
.Add(New SqlParameter("@CrsID", CInt(DropLstCrs.SelectedValue)))
.Add(New SqlParameter("@SubjID", CInt(lstSelSub.Items(i).Value)))
End With
command2.ExecuteNonQuery()
Next
SqlConnection.Close()
DACrsStructure.Fill(DsEduMgnt.COURSE_STRUCTURE)
Response.Redirect("BrowseCrsStructure.aspx")
Actually, I have test both function separately....Both also can work...But when i join both of the function together it unable to perform the add function only....
Do you know why?
Last edited by Nico; 12-18-06 at 11:22 AM.
Reason: Please use [code] wrappers when posting code.
but i don`t think below is error . Because the line 607 is the
Response.redirect("BrowseCrsStructure.aspx")
Thread was being aborted. at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse)
at System.Web.HttpResponse.Redirect(String url) at CrsRegAndAdmission.EditCrsStructure.btnAdd_Click(O bject sender, ImageClickEventArgs e) in C:\Inetpub\wwwroot\CrsRegAndAdmission\EditCrsStruc ture.aspx.vb:line 607