Link to home
Start Free TrialLog in
Avatar of SimonPrice33
SimonPrice33

asked on

SQL Datareader reading from a specific line

Hi,

I have been working with a SQL table and asp.net recently and have been getting my SQL Data reader to read from only a single line in a database table.

Now I would like to read from 1 - 35 lines but only show certain information when called.

I think I am ok with my if statemens in vb.net, but I dont know how to call line one, then the data from that line, then from line two and so on...

Th script that I am currently using is

dim SQLConn As New SQLConnection()
dim SQLcmd As New SQLCommand
dim SQLdr as SQLDataReader

SQLCOnn.ConnectionString = ConnString
SQLConn.Open()

SQLCmd.Connection = SQLConn
SQLCmd.CommandText = SQLStr
SQLdr =  SQLCmd.ExecuteReader

If SQLdr.Read = true then

ObjectivesTxt.Text = SQLdr.Item("OBjective").ToString
GoalTxt.Text = SQLdr.Item("Goal").ToString
Strategy1Txt.Text = SQLdr.Item("Strategy_1").ToString
Measure1Txt.Text = SQLdr.Item("Measure_1").ToString

End if

SQLdr.Close()
SQLConn.Close()

On Each different lines there is a different set of Objectives, Goals Strategies and Meaures and I want to dynamically pull these out on a line by line request.

Any and all help is very much appreciated.

Many thanks

Simon
ASKER CERTIFIED SOLUTION
Avatar of ozi_lion
ozi_lion
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SimonPrice33
SimonPrice33

ASKER

Thanks for your response, I just thought I should use a where statement just before checking back on here.

Many thanks for the help though. As your answer is correct I will mark this as the solution.