Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Datareader reading from a specific line

Posted on 2010-08-29
2
Medium Priority
?
658 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

604 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