multiple reading from db
Hi.. im kinda new on using asp.net. need great help here.
currently im doing the listbox where by the user can multi select the information e.g(Class A). than the information from (Class A) e.g(student's mobile number) will be shown on the textbox. currently i could only display 1 number. any idea to solve my problem? thanks!
Private Sub listbox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox.SelectedIndexChanged
Dim sql, dbcomm, dbread
Dim dbcon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Inetpub\wwwroot\fyr project\bin\DESIGNATION.mdb;")
sql = "SELECT mobile_num FROM STUDENT WHERE pem_grp = '" & listbox.SelectedItem.Text & "' "
dbcomm = New OleDbCommand(sql, dbcon)
Dim reader As OleDbDataReader
Try
dbcon.Open()
reader = dbcomm.ExecuteReader()
reader.Read()
smsTo.Text = reader("mobile_num")
smsTo.Text += "@gSMS, "
smsTo.Text += reader("mobile_num")
reader.Close()
Catch ex As Exception
Finally
If (Not dbcon Is Nothing) Then
dbcon.Close()
End If
End Try
End Sub
|