Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdownlist omits first record 1

Status
Not open for further replies.

bubberz

Programmer
Dec 23, 2004
117
US
I have three records that should be coming back and do come back when I do a SQL string in the Query Analyzer, but the dropdownlist only shows two and ommits the first record. Below is the code:

Dim sqlGrp As String
sqlGrp = "SELECT GC+' - '+GD as Expr2, GC, GD, DC FROM [ResL-Div] WHERE DivisionCode = " & "'" & ddlDivision.SelectedValue.ToString() & "'"
Dim cmdGrp As New OleDbCommand(sqlGrp, Con1)
Con1.Open()
Dim myRDR As OleDbDataReader = cmdGrp.ExecuteReader()
If (myRDR.Read()) Then
ddlGroup2.DataSource = myRDR
ddlGroup2.DataTextField = "Expr2"
ddlGroup2.DataValueField = "GD"
ddlGroup2.DataBind()
End If
Con1.Close()

Thanks!
 
this is because you're

Code:
if myRDR.Read()

reads the first line...so it's already at the second line when you bind the drop down list...

do
Code:
 if myRDR.hasRows = true then

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
checkai,

You rock my friend! Thanks so much!

bubberz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top