shy_wani 0 Light Poster

hi..good day to all..
i want to ask..
i have a page "coverletter.aspx"..
in the page_load, i would like to check whether the surveyID contains any cover letter or not..if there is any, i wanted to load the cover letter and display into textbox letter.text...else..i want to load the default value of coverletter into letter.text

my data in table Survey=SurveyID,SurveyTitle,SurveyDescription,DateCreated,coverletter.
should i use executescalar?

please help..

shy_wani 0 Light Poster

hi..
i wonder, what is wrong with my code? i want to let user update their previous question based on question number they selected.
i have a dropdownlist called qnum. when the qnum index changed, it should load respective question to textbox question.
however, i don't manage to update in the database as the updated question only appear in the page but the question was not being updated in the database.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            butDelete.Attributes.Add("onclick", "return confirm_delete();")
            sqlConn.Open()
            Dim surveyID As String = Request.QueryString("SurveyID")
            Dim queryString As String = "SELECT * FROM Survey Where SurveyID='" & surveyID & "';SELECT * FROM Question WHERE SurveyID='" & surveyID & "'"
            Dim sqlCommand As SqlCommand = New SqlCommand(queryString, sqlConn)
            Dim dataReader As SqlDataReader = sqlCommand.ExecuteReader()
            While dataReader.Read
                title.Text = dataReader("SurveyTitle").ToString
                description.Text = dataReader("SurveyDescription").ToString
            End While
            dataReader.NextResult()
            While dataReader.Read
                With qnum
                    .DataSource = dataReader
                    .DataTextField = "QuestionNum"
                    .DataValueField = "QuestionID"
                    .AutoPostBack = True
                    .DataBind()
                End With
            End While
            dataReader.Close()
            sqlConn.Close()
        End If
    End Sub

    Protected Sub qid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ConnDb(qnum.SelectedItem.Value)
    End Sub

    Protected Sub ConnDb(ByVal qnum As String)
        Dim surveyID As String = Request.QueryString("SurveyID")
        Session("sSurveyID") = surveyID
        sqlConn.Open()
        Dim viewAll As String = "SELECT * FROM Question Where SurveyID='" & surveyID & "' AND QuestionID='" & qnum & "'" 'AND QuestionID=qnum.SelectedValue
        Dim sqlviewAll As SqlCommand = New SqlCommand(viewAll, sqlConn)
        Dim read As SqlDataReader
        read = sqlviewAll.ExecuteReader()
        While read.Read
            question.Text = read("Question").ToString
        End While …
shy_wani 0 Light Poster

OMG...
i'm totally forgot about the not ispostback..
thank you f1 fan for your help..

i believe that sometimes, we can't really see what we are actually doing...haha...

anyway, thanks..thank u very much
:D

shy_wani 0 Light Poster

i have a problem.. i just can't see where i did go wrong..
when my page loads, i want the name and email appear in the textbox so that user can edit their name and email...but then, it doesn't update the record, but continue to save the old value of name and email appear in the textbox when page load

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strConnection As String = ConfigurationSettings.AppSettings("ConnectionString")
        Dim sqlConn As New SqlConnection(strConnection)
        Session("sRespondentID") = Request.QueryString("RespondentID")
        sqlConn.Open()
        If Session("sRespondentID") <> "" Then
            Dim sql As SqlCommand = New SqlCommand("SELECT * FROM Respondent WHERE RespondentID='" & Session("sRespondentID") & "'", sqlConn)
            Dim dr As SqlDataReader
            dr = sql.ExecuteReader
            While dr.Read
                txtName.Text = dr("Name").ToString
                txtEmail.Text = dr("Email").ToString
            End While
            dr.Close()
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strConnection As String = ConfigurationSettings.AppSettings("ConnectionString")
        Dim sqlConn As New SqlConnection(strConnection)
        sqlConn.Open()

        Dim cmd2 As String = "UPDATE Respondent SET Name='" + txtName.Text + "', Email='" + txtEmail.Text + "' WHERE RespondentID = '" & Session("sRespondentID") & "'"
        Dim MyCommand2 As SqlCommand = New SqlCommand(cmd2, sqlConn)
        If MyCommand2.ExecuteNonQuery Then
            Response.Redirect("maillist.aspx")
        Else
            lblMsg.Text = "Record cannot be updated at this moment."
        End If
    
    End Sub

please help me..i cannot see where my mistake

shy_wani 0 Light Poster

i have a dataset

Dim query1 As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM AnswerList WHERE SurveyID=83 AND QuestionNum='" & counter & "'", strConnection)
            Dim ds As New DataSet
            query1.Fill(ds)

how can i refer to specific column for example if i want to search for column QuestionNum=1 in table AnswerList
what i want to do is to perform specific action like this..
if QuestionNum=1 Then
****add controls here
Else if QuestionNum=2 Then
****another new controls here..
Else.....
.....
End if

can anyone tell me how to perform this?

shy_wani 0 Light Poster

i've got this code to create control at runtime..
the problem is that i've forgotten the link and i can't refer to its documentation....
the problem is...i don't understand this line:
Dim parent As String = CStr(ds.Tables(1).Rows(0)("Parent"))

what does this parent refer to?

Dim options As New RadioButtonList
For Each row As DataRow In ds.Tables(0).Rows
Dim item As New ListItem
item.Text = CStr(row("Name"))
item.Value = CStr(row("Id"))
options.Items.Add(item)
Next
Dim parent As String = CStr(ds.Tables(1).Rows(0)("Parent"))
Select Case parent
Case "sideNav"
columnSidenav.Controls.Add(options)
Case "footer"
footerCoontainer.Controls.add(options)
Case Else
paceholderDefault.Controls.add(options)
End Select

~i wanted to learn more~

shy_wani 0 Light Poster

hi..good day to all

i have a table: Question
atttributes: SurveyID(FK),QuestionID(PK),QuestionNum,Question and QuestionTypeID

if i have a dropdown list specifying the list of QuestionNum in my ASPX page and a delete button besides the list, how can i delete one QuestionNum? after delete, how can i shift the Question Number without changing the QuestionID?

examples: SurveyID=140 has QuestionNum=10
so, QuestionNum would be from 1-10...
if i were to delete QuestionNum=3...i want to delete QuestionNum=3 and at the same time, i want other QuestionNum after the deleted ones (means, QuestionNum=4 to QuestionNum=10) to shift their value...means...Question=4 is now QuestionNum=3,QuestionNum=5 to be QuestionNum=4, and so on...

how can i perform this? please help me..

shy_wani 0 Light Poster

hi..good day to all

i have a table: Question
atttributes: SurveyID(FK),QuestionID(PK),QuestionNum,Question and QuestionTypeID

if i have a dropdown list specifying the list of QuestionNum in my ASPX page and a delete button besides the list, how can i delete one QuestionNum? after delete, how can i shift the Question Number without changing the QuestionID?

examples: SurveyID=140 has QuestionNum=10
so, QuestionNum would be from 1-10...
if i were to delete QuestionNum=3...i want to delete QuestionNum=3 and at the same time, i want other QuestionNum after the deleted ones (means, QuestionNum=4 to QuestionNum=10) to shift their value...means...Question=4 is now QuestionNum=3,QuestionNum=5 to be QuestionNum=4, and so on...

how can i perform this? please help me..

shy_wani 0 Light Poster

ok..ok
finally i understand..
now i've changed my column DateCreated in MSSQL to accept null values..

and inside my form at ASP.NET..i've changed my sql statement to..

sql2 = "INSERT INTO Survey(CustomerID,SurveyTitle,SurveyDescription,DateCreated) VALUES('" & Session("sCustomerID") & "','" & strTitle & "','" & strDescription & "',CURRENT_TIMESTAMP)"

and now it's finally work..

shy_wani 0 Light Poster

hi..
i've created a table named :Survey

CREATE TABLE [dbo].[Survey] (
    [CustomerID] [int] NOT NULL ,
    [SurveyID] [int] IDENTITY (1, 1) NOT NULL ,
    [SurveyTitle] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [SurveyDescription] [varchar] (300) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [DateCreated] AS (getdate()) ,
    [coverletter] [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

my problem is regarding my DateCreated.. when system created through my page in aspx, the survey input are correctly stored in the database except for DateCreated where the whole table Column DateCreated changes its date to date at time the last survey was created....

my code for inserting in survey.aspx

Dim strTitle As String = title.Text
Dim strDescription As String = description.Text   
sql2 = "INSERT INTO Survey(CustomerID,SurveyTitle,SurveyDescription) VALUES('" & Session("sCustomerID") & "','" & strTitle & "','" & strDescription & "')"
            cmd2 = New SqlCommand(sql2, MyConnection)
            cmd2.ExecuteNonQuery()

where did i go wrong? please guide me..

shy_wani 0 Light Poster

hi..
i've created a table named :Survey

CREATE TABLE [dbo].[Survey] (
    [CustomerID] [int] NOT NULL ,
    [SurveyID] [int] IDENTITY (1, 1) NOT NULL ,
    [SurveyTitle] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [SurveyDescription] [varchar] (300) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [DateCreated] AS (getdate()) ,
    [coverletter] [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

my problem is regarding my DateCreated.. when system created through my page in aspx, the survey input are correctly stored in the database except for DateCreated where the whole table Column DateCreated changes its date to date at time the last survey was created....

my code for inserting in survey.aspx

Dim strTitle As String = title.Text
Dim strDescription As String = description.Text   
sql2 = "INSERT INTO Survey(CustomerID,SurveyTitle,SurveyDescription) VALUES('" & Session("sCustomerID") & "','" & strTitle & "','" & strDescription & "')"
            cmd2 = New SqlCommand(sql2, MyConnection)
            cmd2.ExecuteNonQuery()

where did i go wrong? please guide me..

shy_wani 0 Light Poster

hi..i'm doing my final year project on creating Questionnaires template. i have problem with viewing my OptionLIst. I have 2 dataset..all i want to do is to preview all my Question & Answer..i can view them, but i need to create textboxes or checkboxes besides the OptionList..

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
 Dim questDA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM Question WHERE SurveyID=83", MyConnection)
        Dim surveyDA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM AnswerList WHERE SurveyID=83", MyConnection)
        Dim custDS As DataSet = New DataSet
        questDA.Fill(custDS, "Question")
        surveyDA.Fill(custDS, "AnswerList")
        MyConnection.Close()

        Dim custAnswerListrel As DataRelation = custDS.Relations.Add("CustAnswerList", _
                                             custDS.Tables("Question").Columns("QuestionID"), _
                                             custDS.Tables("AnswerList").Columns("QuestionID"))
        Dim pRow, cRow As DataRow
        Dim radlist As New RadioButtonList
        For Each pRow In custDS.Tables("Question").Rows
            Response.Write("<br>")
            'Response.Write(pRow("QuestionID").ToString())
            Response.Write(pRow("QuestionNum").ToString())
            Response.Write(pRow("Question").ToString())
            Response.Write("<br>")
            Response.Write(pRow("QuestionTypeID").ToString())
'suppose if QuestionTypeID="Radio" then the OptionList below should 'be listed wit RadioButton, else if QuestionTypeID="CheckBoxes"
'then the OptionList below should be listed with checkboxes...
            Response.Write("<br>")
            For Each cRow In pRow.GetChildRows(custAnswerListrel)
                Dim li As ListItem = New ListItem(cRow("OptionList"), cRow("OptionID"))
                         Response.Write(vbTab & cRow("OptionID").ToString())
                'Dim li As ListItem = New ListItem(cRow("OptionList"), cRow("OptionID"))
                Response.Write(cRow("OptionList").ToString())
                Response.Write("<br>")
            Next
        Next
InitializeComponent()
End Sub

can anyone help me? please...i really need your help..

shy_wani 0 Light Poster

hi..
i'm having a table called "Survey". Whenever user create survey, it will store the date and time the survey was created.

CREATE TABLE [dbo].[Survey] (
    [CustomerID] [int] NOT NULL ,
    [SurveyID] [int] IDENTITY (1, 1) NOT NULL ,
    [SurveyTitle] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [SurveyDescription] [varchar] (300) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [DateCreated] AS (getdate()) ,
    [coverletter] [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]

right now..all the survey created by user are the the same for each record..
i guess i shouldn't use getdate()
what should i do to resolve this?
please help...

shy_wani 0 Light Poster

In addition...Right now, all the controls didn't show up in page_load\

where did i do wrong?


~i want to learn~

shy_wani 0 Light Poster

hi..
i wanna ask...how can i add controls such as RadioButton @ CheckBoxes @ TextBox into panel?

i need to view my OptionList based on my QuestionType

Dim sql As SqlCommand=("SELECT Question.QuestionTypeID,AnswerList.OptionID,AnswerList.OptionList FROM QUESTION, AnswerList WHERE AnswerList.SurveyID = 83 AND AnswerList.QuestionNum=1",MyConn)
Dim readQ As SqlDataReader = sql.ExecuteReader()

 While readQ.Read
            Dim qtype As String = readQ("QuestionTypeID").ToString
            If qtype = 1 Then
                Dim rad As New RadioButtonList
                With rad
                    .DataSource = readQ
                    .DataValueField = "OptionID"
                    .DataTextField = "OptionList"
                    putOption.Controls.Add(rad)
            
                End With
            ElseIf qtype = 2 Then
                Dim chk As New CheckBoxList
                With chk
                    .DataSource = readQ
                    .DataValueField = "OptionID"
                    .DataTextField = "OptionList"
                    putOption.Controls.Add(chk)
                End With
            Else
                Dim txtbox As New TextBox
                putOption.Controls.Add(txtbox)
            End If
        End While

fyi, putOption is the panel which i want to insert my controls...

please guide me..help is very much appreciated..

shy_wani 0 Light Poster

ok...thanks hollystyles

now i've already got the solution...

i'm jumping all over my tv hall...yey!!!!

shy_wani 0 Light Poster

ok..
i made up my mind that their selection to be actioned immediately they select it in the drop down control...
if so, then i don't need the button right?
so..does it mean that i should add SelectedIndexChanged into my drop down control?

<asp:Dropdownlist id=qnum runat="server" DataValueField="QuestionID" DataTextField="QuestionNum" OnSelectedIndexChanged="populateOption()"/>

then at
sub populateOption(......)
--generate OptionList to lstOptions----

am i right until here?

shy_wani 0 Light Poster

The code you post has no handler for the SelectedIndexChange event of your drop down control, instead you have a button click handler. So to cause the List box to be rebound, in your programs current state, you need to make a selection in the drop down and then click the submit button every time to get a change in the list box.

can u elaborate more? i can't figured out where to add the handler? does it mean that i don't need a button click handler?
hope u can help me....your help is very much appreciated...

shy_wani 0 Light Poster

what is wrong with my code?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

MyConnection.Open()
Dim strSQL As String = "SELECT * FROM Question WHERE SurveyID=83 Order By QuestionNum"
Dim cnCommand1 As SqlCommand = New SqlCommand(strSQL, MyConnection)
Dim Rdr As SqlDataReader = cnCommand1.ExecuteReader() 'execute reader to catch data from db to drop dwon lists

With qnum
.DataSource = Rdr
.DataValueField = "QuestionID"
.DataTextField = "QuestionNum"
.DataBind()
End With

'Rdr.NextResult()
'With lstOptions
' .DataSource = Rdr
' .DataValueField = "OptionID"
' .DataTextField = "OptionList"
' .DataBind()
'End With
'close the reader
Rdr.Close()

End Sub

Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim questid As String = qnum.SelectedItem.Value
For Each s As String In questid
Dim sql As String = "SELECT * From AnswerList WHERE SurveyID=83 AND QuestionID='" & questid & "' Order By QuestionNum"
Dim cmd As SqlCommand = New SqlCommand(sql, MyConnection)
Dim reader As SqlDataReader
reader = cmd.ExecuteReader

With lstOptions
.DataSource = reader
.DataValueField = "OptionID"
.DataTextField = "OptionList"
.DataBind()
End With

reader.Close()

Next

'Close the DB Connection
MyConnection.Close()
End Sub

i want to populate the lstOptions (a listbox) based on the item selected in frop down list named "qnum"

the problem is..the data in lstOptions changed only at first time the dropdown …

shy_wani 0 Light Poster

what is wrong with my code?

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        MyConnection.Open()
       Dim strSQL As String = "SELECT * FROM Question WHERE SurveyID=83 Order By QuestionNum"
        Dim cnCommand1 As SqlCommand = New SqlCommand(strSQL, MyConnection)
        Dim Rdr As SqlDataReader = cnCommand1.ExecuteReader()    'execute reader to catch data from db to drop dwon lists

        With qnum
            .DataSource = Rdr
            .DataValueField = "QuestionID"
            .DataTextField = "QuestionNum"
            .DataBind()
        End With

        'Rdr.NextResult()
        'With lstOptions
        '    .DataSource = Rdr
        '    .DataValueField = "OptionID"
        '    .DataTextField = "OptionList"
        '    .DataBind()
        'End With
        'close the reader
        Rdr.Close()

        

    End Sub

    Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim questid As String = qnum.SelectedItem.Value
        For Each s As String In questid
            Dim sql As String = "SELECT * From AnswerList WHERE SurveyID=83 AND QuestionID='" & questid & "' Order By QuestionNum"
            Dim cmd As SqlCommand = New SqlCommand(sql, MyConnection)
            Dim reader As SqlDataReader
            reader = cmd.ExecuteReader

            With lstOptions
                .DataSource = reader
                .DataValueField = "OptionID"
                .DataTextField = "OptionList"
                .DataBind()
            End With

            reader.Close()

        Next

        'Close the DB Connection
        MyConnection.Close()
    End Sub

i want to populate the lstOptions (a listbox) based on the item selected in frop down list named "qnum"

the problem is..the data in lstOptions changed only at first time the dropdown list value change...the 2nd,3rd change of the dropdownlist, the lstOptions value doesn't change

plzz help me...

shy_wani 0 Light Poster

hi..

i have draft.aspx
at first time view, i want the draft.aspx to take value QuestionNum in the database...so, at first time viewing, the draft.aspx shows QuestionNum.text=1

i have a button - "Next". i want user to click the button and they will be redirected to the draft.aspx displaying the second question and so on..

how could this be done? is it got anything to do with the postback? or shall i be using querystring, or sessions perhaps? i've tried using the querystring, but the page when draft.aspx went black for question number 2...

can anyone help me understand this problem?

shy_wani 0 Light Poster

hi..

is anyone knows..how to add controls dynamically in a page according to user input? at page 1, user will define their data (OptionList) and its data representation style(eg checkbox,listbox,radiobutton or whatsoever) for each question..then when user click submit, all data sets by user in Page 1 will be previewed at Page2.aspx

explanation:
Question 1:user set to display data with checkboxes..
Question 2: user set data in radio button..
and so on..

can anyone help me?

shy_wani 0 Light Poster

hi..good day to all..
i have a datagrid that combines 2 related tables as below:
<body>
<asp:datagrid id="dlQuestion" runat="server">
<ItemTemplate>
<b>Question :#</b>
<%# Container.DataItem("QuestionNum") %><br>
<%# Container.DataItem("Question") %>
<asp:DataList runat="server" Id="ChildDataList"
datasource='<%#Container.DataItem.Row.GetChildRows("myrelation") %>' RepeatColumns="1">
<ItemTemplate>
<%# Container.DataItem("OptionList") %>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:datalist>
</body>

the code behind as shown below:
Dim MySQL As String = "Select * from Question"
Dim ds As DataSet = New DataSet
Dim Cmd As New SqlDataAdapter(MySQL, MyConnection)
Cmd.Fill(ds, "Question")
Dim cmd2 As SqlDataAdapter = New SqlDataAdapter("select * from AnswerList", MyConnection)
cmd2.Fill(ds, "AnswerList")
ds.Relations.Add("myrelation", ds.Tables("Question").Columns("QuestionID"), ds.Tables("AnswerList").Columns("QuestionID"))

dlQuestion.DataSource = ds.Tables("Question").DefaultView
DataBind()


is it possible to display the AnswerList in radio button or checkboxes? in table Question..i have attribute "QuestionType" that defines whether the QuestionType="MultipleSingle" then it should be displayed with radio button, else if QuestionType="MultipleMultiple" the answerlist will display checkbox..
how can this be done??
please..if u guys can't help me with the code, perhaps with a suggestion of how i'm gonna solve this would be really helpful...thanks

shy_wani 0 Light Poster

thanks ManicCW

but how can I call the Title & Description to be in the textbox?

shy_wani 0 Light Poster

hi..
i have problem...which i don;t know how to perform this action..
i have a page...named "preview.aspx". this page should preview all the Question with their Answer List
example of Question: What is the temperature of boiling water?
example of Answer : 100 degrees Celcius, 120 degrees Celsius, 80 degrees, and so on....

i can managed to view all the question in the preview.aspx using the data reader..
but i have problem to call the Answer List. b'coz i've created different user control file (.ascx) for different type of question...for example: if user want to view their set of question with radio button for question 1..then it will call Set1.ascx....if want to view answer in drop down list, call Set2.ascx

huhu..how to call the .ascx files?

please somebody help!!

shy_wani 0 Light Poster

hi..
i want to ask if anyone knows how to do this..

i have a datagrid at my "home.aspx" with attribute 'Survey Title' and 'Description'
i also have an edit button that will redirect user to "surveyeditor.aspx"
in "surveyeditor.aspx", there are 2 textbox..which can be used to edit the 'Survey Title' and 'Description'

how to get the Survey Title and Description data so that when "surveyeditor.aspx" page loads, the value Survey Title and Description from previos page appear into the textboxes...(all the user have to do is to edit from the textbox)

can this be done?

please somebody guide me...

shy_wani 0 Light Poster

hi..

is anyone know..i have all the information about how a question should be displayed from database so that customer may review their survey question?

for examples:
Table 1: Question -
QuestionID, QuestionNum, Question, QuestionStyle
Table 2: Answer -
AnswerID, QuestionID, QuestionNum, AnswerList

eg:
QuestionID=from 1 to 10
QuestionNum=from 1 to 10
Question={examples: When Malaysia declares their Independence Day?}
QuestionStyle=MultipleSingle,MultipleMultiple,BooleanYesNo
{examples: if user select "MultipleSingle" then the preview would be in dropdown list or radio button, etc..that requires only single selection}

how to generate a various set of list that differs according to user settings of styles in something like html form?

aiyak...
it's like...if user select MultipleSingle question type for question number1..then it will display something like this:

Question 1
<the question goes here...blabablabla>
<list of radio button here from the answer list>

Question 2
<the question goes here...blabablabla>
<list of checkboxes here from the answer list>

and so on...

do anyone know how to create a template like this?

shy_wani 0 Light Poster

owh..thanks nitinmms

now i understand...this problem has been bugging me since last week..haha..

thanks again yer...
take care

shy_wani 0 Light Poster

hi..
my system should select the maximum QuestionNum from one of the my table in the database. after all, i would like to increment the value QuestionNum to 1...
but i keep on receiving error
"Cast from type 'DBNull' to type 'String' is not valid."

this is my code...

Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim MyConnection As SqlConnection
MyConnection = New SqlConnection("server=localhost;database=xxxxxxx;Trusted_Connection=yes")
MyConnection.Open()
Dim sql As String
//Select the max QuestionNum where SurveyID=SurveyID
sql = "SELECT MAX(QuestionNum) FROM Question WHERE SurveyID='" & Session("sSurveyID") & "'"
Dim cmd As New SqlCommand(sql, MyConnection)
Dim QuestionNum As Integer
Dim id As String
id = cmd.ExecuteScalar
QuestionNum = id
MyConnection.Close()
End If
End Sub


p/s: can anyone explain what is wrong here?

shy_wani 0 Light Poster

dear hollystyles...
this method works....
thank u...
arigatou gozaimas...
hope someday i'll be master in programming... :p

shy_wani 0 Light Poster

aiyak..
but what if i want user to enter their choices...

my program is like...
i want to create a survey creator system..
user will enter their question..1 question may have more than 1 answers...
i want user to enter their choices..one question per line, then i'm gonna save the option line by line as list of options into my database b4 the system generate the template..

so..right now, my problem is to reaa line by line text in the textbox..and to save the list of options into database..

can u help me?

shy_wani 0 Light Poster

hehe....thanks ya hollystyles..
may God bless u...

shy_wani 0 Light Poster

thanks for your help..
so...i must use listbox ya? hehe..thanks
but...
this is c#...
can u write in vb.net?

huhu....

shy_wani 0 Light Poster

hi..i'm new in using ASP.NET application. Please guide me as i've only about 30% knowledge on developing web application in .NET

ok..my problem is..
i have a textbox..
i wanted user to create multiple option by entering each option per line in the textbox...
in other words..if user want to enter 4 option, 1st option will be at 1st line, 2nd option at 2nd line....and so on..

so..when i create button "Submit"..it will automatically assume that data in the first line will be inserted to first row in table in my database...

can this be done? please somebody help me...