Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Add and Delete function can perform together at the same time?


Add and Delete function can perform together at the same time?

Reply
  #1 (permalink)  
Old 12-18-06, 10:58 AM
Elaine Elaine is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #2 (permalink)  
Old 12-18-06, 11:04 AM
koncept
Guest
 
Posts: n/a
if they work separately then you should be able to join them without a problem. are you recieving any type of error messages? if so can you post them
Reply With Quote
  #3 (permalink)  
Old 12-18-06, 11:35 AM
Elaine Elaine is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,koncept

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
Reply With Quote
  #4 (permalink)  
Old 12-18-06, 12:29 PM
Elaine Elaine is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Hi, koncept...

I had find out the problem ....
Anyway..thanks for ur help too
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 03:54 PM
HOw to add, update, edit, delete record in 2 tables? andrew123 ASP 4 01-24-06 04:28 PM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
View, edit, delete and add data to a database bigkid PHP 9 07-21-04 11:51 PM
PHP Error Fairnie PHP 8 06-26-04 07:15 AM


All times are GMT -5. The time now is 02:30 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.