Solved

SQL Datareader reading from a specific line

Posted on 2010-08-29
2
640 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
2 Comments
 
LVL 2

Accepted Solution

by:
ozi_lion earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now