•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,269 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,440 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1233 | Replies: 0 | Solved
![]() |
| |
•
•
Join Date: Mar 2007
Posts: 34
Reputation:
Rep Power: 2
Solved Threads: 0
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.
please..somebody help!!!
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
read.Close()
sqlConn.Close()
End Sub
Private Sub butSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSave.Click
Try
Dim strqnum As String = qnum.SelectedItem.Value
Dim strquestion As String = question.Text.Trim
Dim sql As String = "UPDATE Question SET Question='" & strquestion & "' WHERE QuestionNum='" & strqnum & "'"
Dim mycmd As SqlCommand = New SqlCommand(sql, sqlConn)
sqlConn.Open()
mycmd.ExecuteNonQuery()
Catch ex As Exception
lblnotify1.Text = "The following database error occured:" + _
ex.Message()
sqlConn.Close()
End Try
End Subplease..somebody help!!!
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
- Windows Update problem (Windows Vista)
- System Formatted-Update problem (Windows NT / 2000 / XP / 2003)
- Firefox problem - can't install update and Thunderbird -"fights" with Netscape! (Windows NT / 2000 / XP / 2003)
- ComboBox UpDate Problem (VB.NET)
- Windows Update Problem (Windows NT / 2000 / XP / 2003)
- WMI Update Problem (Windows NT / 2000 / XP / 2003)
- Big Time Bug On New Windows Update (Windows NT / 2000 / XP / 2003)
Other Threads in the ASP.NET Forum
- Previous Thread: to change panel color using javascript
- Next Thread: check certain values in db contains value or not..


Hybrid Mode