?
Solved

SQL Datareader reading from a specific line

Posted on 2010-08-29
2
Medium Priority
?
654 Views
Last Modified: 2012-05-10
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
Comment
Question by:SimonPrice33
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
ozi_lion earned 2000 total points
ID: 33552372
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
 

Author Comment

by:SimonPrice33
ID: 33552389
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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question