Reading through a datareader

  • Thread starter Thread starter Sam anonymous
  • Start date Start date
S

Sam anonymous

This is what I have so far but if someone could show me how to read
through the datareader once I can get the rest.
Thank you.


Private Sub lstCoursesOffered_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lstCoursesOffered.SelectedIndexChanged
Dim intcount As Integer = 0
mblnLoading = True
If Not mblnStart Then
Dim clsCoursesOffered As New CClassReader()
clsCoursesOffered.Courses =
mstrCoursesOffered(lstCoursesOffered.SelectedIndex)
Call clsCoursesOffered.SelectCourse()
????? Move clsClass.fieldnames to txtboxes: txtSection, txtCallNbr,
txtEnroll, txtMaxEnroll,
txtWebVideo(, txtSpecialComment, txtTermID)

Load the meeting days checked boxes

?????? Read through the datareader finding the matching DeptId in the
cboDeptId
Set it to be selected

Read through the datareader finding the matching CourseID in the
cboCourseID
Set it to be selected

Read through the datareader finding the matching InstrName in the
cboInstrName
Set it to be selected

Read through the datareader finding the matching
BuildRoomID in the cboBuildRoom
Set it to be selected

Read through the datareader finding the matching ClassType in the
cboClasstype
Set it to be selected

Read through the datareader finding the matching Status in the
cboStatus
Set it to be selected

End If
End Sub
 
Hi,

Here is the code for a sample console app.

Imports System.Data.SqlClient

Module Module1

Sub Main()
Dim strConn As String
Dim conn As SqlConnection
Dim drCustomer As SqlDataReader
Dim cmd As SqlCommand

strConn = "Server = " + Environment.MachineName + ";"
strConn += "Database = NorthWind;"
strConn += "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)
cmd = New SqlCommand("Select * from Customers", conn)
conn.Open()
drCustomer = cmd.ExecuteReader
Do While drCustomer.Read
Console.WriteLine(drCustomer("CustomerID"))
Loop
conn.Close()

End Sub

End Module


Ken
 
Back
Top