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").To String
GoalTxt.Text = SQLdr.Item("Goal").ToStrin g
Strategy1Txt.Text = SQLdr.Item("Strategy_1").T oString
Measure1Txt.Text = SQLdr.Item("Measure_1").To String
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
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").To
GoalTxt.Text = SQLdr.Item("Goal").ToStrin
Strategy1Txt.Text = SQLdr.Item("Strategy_1").T
Measure1Txt.Text = SQLdr.Item("Measure_1").To
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks for the help though. As your answer is correct I will mark this as the solution.