Hey guys! Can someone help me.? I have two tables named Questions and Examination, and two listviews named lstQuestion and lstChosenQuestion. I transfer the value of my lstQuestion to lstChosenQuestion through drag and drop and I already did that. My problem is saving the QuestionNumber equivalent of the transfered value on my second listview to sql DB, where in I am comparing the value of transfered data to its QuestionNumber equivalent from table Question, and saving the QuestionNumber equivalent to Examination table. Woah! I'm so sorry, it's kinda confusing, still, I hope someone can help me! Thanks! God Bless. :)
mycurrentconnection.Open() If lstChosenQuestion.Items.Count = 0 Then 'dset.Tables("Applicant").Rows.Count = 0 MsgBox("No record(s) found.") Else MsgBox("Question Chosen!") With mycommandQuestion Dim Find As String Find = "SELECT QuestionNumber FROM Question WHERE Question = '" & lstChosenQuestion.Text & "'" myreader = .ExecuteReader End With myreader.Read() If myreader.HasRows Then With mycommandSaveQuestion .CommandType = CommandType.Text .CommandText = "INSERT INTO Examination SELECT QuestionNumber = '" & Val(myreader("QuestionNumber").ToString) & "' " .Connection = mycurrentconnection myreader2 = .ExecuteReader End With myreader2.Read() myreader2.Close() End If myreader.Close() End If mycurrentconnection.Close()
That's my code, there is an error saying "IndexOutOfRangeException was unhandled"