Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 665
  • Last Modified:

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
0
SimonPrice33
Asked:
SimonPrice33
1 Solution
 
ozi_lionCommented:
Hi,
you should use where statement in your SQL text to say from which line you will get data you want otherwise you will always see just the last record in your table.
0
 
SimonPrice33Author Commented:
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.

0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now