| |
|||
Наконец, устанавливается связь между элементом управления DropDownList и таблицей CurrentResponses объекта DataSet:
DSQuestion.Tables("CurrentResponses").DefaultView ddlResponses.DataBind()
Session("CurrentSequenceNumber") = _ Session("CurrentSequenceNumber") + 1 Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSQuestion as DataSet Dim DBInsert As New OleDbCommand DBConn = New OleDbConnection("Provider=sqloledb;" _ & "server-localhost;" _ & "Initial Catalog=INETC10;" & "User Id=sa;" _ 4 "Password=yourpassword;") DSQuestion = New DataSet() DBCommand = New OleDbDataAdapter _ ("Select ChoiceText, ChoiceCost " _ & "From QuestionChoices Where " _ & "ChoicelD = " _ & ddlResponses.Selectedltern.Value,DBConn) DBCommand.Fill(DSQuestion, _ "Choicelnfo") DBInsert.CommandText = "Insert Into TJrderChoices " _ & "(ObjectOrderlD, ChoicelD, ChoiceText, ChoiceCost) " _ & "values (" _ & Session ("ObjectOrderlD'') & ", " _ & ddlResponses.Selectedltem.Value & ", '" _ & DSQuestion.Tables("Choicelnfo") .Rows(0).Item("ChoiceText") _ &" '," _ & DSQuestion.Tables("Choicelnfo") _ .Rows(0).Item("ChoiceCost") _ & ") " DBInsert.Connection - DBConn DBInsert.Connection.Open DBInsert.ExecuteNonQuery() DBCommand = New OleDbDataAdapter _ ("Select ObjectQuestionID, " _ & "ObjectQuestionText, PicPath, " _ & "PicAltText from ObjectQuestions " _ & "Where Sequence = " _ & Session("CurrentSequenceNumber"),DBConn) DBCommand.Fill(DSQuestion, _ "CurrentQuestion") If DSQuestion.Tables("CurrentQuestion").Rows.Count = 0 Then Response.Redirect("./summary.aspx") End If DBCommand = New OleDbDataAdapter _ ("Select ChoicelD, ChoiceText " _ & "From QuestionChoices " _ & "Where ObjectQuestionID = " _ & DSQuestion.Tables("CurrentQuestion") _ .Rows(O).Item("ObjectQuestionID"> ,DBConn) DBCommand.Fill(DSQuestion, _ "CurrentResponses") imgStepPicture.AlternateText = _ DSQuestion.Tables("CurrentQuestion").Rows(0).Item("PicAltText") imgStepPicture.ImageUrl = _ DSQuestion.Tables("CurrentQuestion").Rows(O).Item("PicPath") _ IblQuestion.Text = _ DSQuestion.Tables("CurrentQuestion")_ .Rows(O).ItemC'ObjectQuestionText") ddlResponses.DataSource = _ DSQuestion.Tables("CurrentResponses").Defaultview ddlResponses.DataBind() End Sub
Session("CurrentSequenceNumber") + 1
("Select ChoiceText, ChoiceCost " _ & "From QuestionChoices Where " & "ChoicelD = " _ & ddlResponses.Selectedltem.Value,DBConn)
"Choicelnfo") |
|||