Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
I am working on a survey system, but I have a problem im my code, I want help.... :confused:

VB.NET
Partial Class deptcp_Default3

    Inherits System.Web.UI.Page



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If String.IsNullOrEmpty(Request.QueryString("SURVEY_ID")) Then

            Else
                '  qid.Value = Request.QueryString("qid")
            End If
        End If
        Dim con As New OracleConnection(ConfigurationManager.ConnectionStrings("orcl").ConnectionString)
        Dim comm As New OracleCommand
        Dim sur As Integer
        sur = Request.QueryString("SURVEY_ID")
        Dim par10par As New OracleParameter("par10", sur)
        comm.Parameters.Add(par10par)
        '       Try
        comm.Connection = con
        comm.Connection.Open()
        comm.CommandText = "select QUESTION_ID, QUESTION_TEXT,TYPE_OF_QUESTION from SURVEY_QUESTION where SURVEY_ID= :par10"
        Dim r As OracleDataReader = comm.ExecuteReader
        If r.HasRows Then
            While r.Read
                Dim a As Label
                a = New Label
                a.Text = "</br>" & r(("QUESTION_TEXT")) & "<br/>"
                Panel1.Controls.Add(a)
                If r("TYPE_OF_QUESTION") = "OPEN" Then
                    Dim r3 As TextBox
                    r3 = New TextBox
                    r3.ID = "OPE" & r("QUESTION_ID")

                    r3.TextMode = TextBoxMode.MultiLine
                    Panel1.Controls.Add(r3)
                End If

                Dim ab As New OracleConnection(ConfigurationManager.ConnectionStrings("orcl").ConnectionString)
                Dim mm As New OracleCommand
                mm.Connection = ab
                mm.Connection.Open()
                mm.CommandText = "select ANSWER_ID,ANSWER_CH from SURVEY_ANSWER where QUESTION_ID= :par11"

                Dim par11par As New OracleParameter("par11", r("QUESTION_ID").ToString())
                mm.Parameters.Add(par11par)



                Dim r2 As OracleDataReader = mm.ExecuteReader
                If r("TYPE_OF_QUESTION") = "ONE CHOICE" Then
                    Dim dd As New RadioButtonList
                    dd.DataSource = r2
                    dd.DataTextField = "ANSWER_CH"
                    dd.DataValueField = "ANSWER_ID"
                    dd.ID = "radio_b" & r("QUESTION_ID")
                    dd.DataBind()
                    Panel1.Controls.Add(dd)

                Else


                    If r("TYPE_OF_QUESTION") = "MULTIPLE" Then
                        Dim dd1 As New CheckBoxList
                        dd1.DataSource = r2
                        dd1.DataTextField = "ANSWER_CH"
                        dd1.DataValueField = "ANSWER_ID"
                        dd1.ID = "check_b" & r("QUESTION_ID")
                        dd1.DataBind()
                        Panel1.Controls.Add(dd1)



                    End If
                    


                End If



            End While



        Else
            ' Response.Redirect("Error.aspx")

        End If



        r.Close()
        con.Close()












        If String.IsNullOrEmpty(Request.QueryString("SURVEY_ID")) Then
            Response.Write("true")
        Else
            Response.Write("false")
        End If

        If String.IsNullOrEmpty(Request.QueryString("EMP_ID")) Then
            Response.Write("true")
        Else
            Response.Write("false")
        End If
        Dim su As Integer
        su = (Request.QueryString("SURVEY_ID"))

        Dim em As Integer
        em = (Request.QueryString("EMP_ID"))
        Dim oraconn As New OracleConnection(ConfigurationManager.ConnectionStrings("orcl").ConnectionString)
        Dim oraquery As String = "select SURVEY_ID , EMP_ID from EMP_SUR where SURVEY_ID= :par1 and EMP_ID= :par2"
        Dim oracommand As OracleCommand = New OracleCommand(oraquery, oraconn)
        oraconn.Open()
        Dim par1 As New OracleParameter("par1", su)
        oracommand.Parameters.Add(par1)

        Dim par2 As New OracleParameter("par2", em)
        oracommand.Parameters.Add(par2)


        Dim reader As OracleDataReader = oracommand.ExecuteReader()
        If reader.HasRows Then

            Response.Write("             ")
            While reader.Read
                reader("SURVEY_ID").ToString()
                Response.Write(su)
                reader("EMP_ID").ToString()
                Response.Write(em)

            End While
        Else
            ' Response.Redirect("Error.aspx")
        End If

        reader.Close()

        oraconn.Close()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        Dim ab1 As New OracleConnection(ConfigurationManager.ConnectionStrings("orcl").ConnectionString)
        Dim mm1 As New OracleCommand
        Dim sur1 As Integer
        sur1 = Request.QueryString("SURVEY_ID")
        Dim par144par As New OracleParameter("par144", sur1)
        mm1.Parameters.Add(par144par)
        mm1.Connection = ab1
        mm1.Connection.Open()
        mm1.CommandText = "select QUESTION_ID, QUESTION_TEXT,TYPE_OF_QUESTION from SURVEY_QUESTION where SURVEY_ID= :par144"

        Dim r4 As OracleDataReader = mm1.ExecuteReader
        mm1.Parameters.Clear()

        mm1.CommandText = "insert into RESULTS(TEXT_OF_ANSWER,QUESTION_ID)  values(:FF,:VV) "
        If r4.HasRows Then
            While r4.Read
                If r4("TYPE_OF_QUESTION") = "OPEN" Then
                    Dim a1 As TextBox = CType(Panel1.FindControl("OPE" & r4("QUESTION_ID")), TextBox)
                    Dim FFpar As New OracleParameter("FF", a1.Text)
                    mm1.Parameters.Add(FFpar)
                    Dim a2 As Integer = r4("QUESTION_ID")

                    Dim VVpar As New OracleParameter("VV", OracleType.Int32)
                    VVpar.Value = Integer.Parse(a2)
                    mm1.Parameters.Add(VVpar)
                    mm1.ExecutAeNonQuery()
                End If

                Dim ab2 As New OracleConnection(ConfigurationManager.ConnectionStrings("orcl").ConnectionString)
                Dim mm2 As New OracleCommand
                mm2.Connection = ab2
                mm2.Connection.Open()


                If r4("TYPE_OF_QUESTION") = "ONE CHOICE" Then
                    Dim a7 As RadioButtonList = CType(Panel1.FindControl("radio_b" & r4("QUESTION_ID")), RadioButtonList)

                    Dim FFApar As New OracleParameter("FFA", a7.SelectedValue)
                    mm1.Parameters.Add(FFApar)


                    mm2.CommandText = "update SURVEY_ANSWER set COUNTER =counter + 1 where ANSWER_ID=:FFApar "

                    mm2.ExecuteNonQuery()






                Else

                    If r4("TYPE_OF_QUESTION") = "MULTIPLE" Then

                        mm2.CommandText = "update SURVEY_ANSWER set COUNTER =counter + 1 where= ANSWER_ID=QUESTION_ID "

                        r4.Close()
                        ab1.Close()

                    End If

                End If


                End If

            End While


        End If



    End Sub
End Class
Posted
Updated 22-Sep-10 22:13pm
v3
Comments
Tom Deketelaere 22-Sep-10 10:55am    
Nobody is going to read all that code for you.
Post only the code that is relevant (the part where things go wrong)
And explain your question more clearly.
What is it that goes wrong, what is it that the code is supposed to do and what does it actually do.
Do you get a error message, if so post it.
As it is now, I doubt very much that anyone is going to be able or willing to provide you with a solution.
ARopo 22-Sep-10 10:56am    
It might help if you say what the problem with the code is.
Sandeep Mewara 22-Sep-10 12:44pm    
before code, you have problem posting it! :doh:
Johnny J. 23-Sep-10 4:14am    
And I want a million bucks... How about asking nicely? A "Please" would help a little!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900