473,382 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Displaying single record

This I'm sure is a silly question, but I am pulling one
field from one particular record and for the life of me
can't figure out how to display/manipulate it. Every
single tutorial or code sample relating asp.net and
database access uses a datagrid, which doesn't help me
here. Can someone please direct me to a resource that
shows the asp.net equivalent of the below code?

strSQL = "SELECT field FROM table WHERE id=1"

Set objRS = objConn.Execute(strSQL)

Response.Write objRS("field")

Thanks,

Josh
Nov 18 '05 #1
2 1298
"Josh" <an*******@microsoft.com> wrote in news:b7c901c47986$2fa35b70
$a*******@phx.gbl:
This I'm sure is a silly question, but I am pulling one
field from one particular record and for the life of me
can't figure out how to display/manipulate it. Every
single tutorial or code sample relating asp.net and
database access uses a datagrid, which doesn't help me
here. Can someone please direct me to a resource that
shows the asp.net equivalent of the below code?

Are you using a dataset or datareader?
Dataset:

label.text = ds.table(0).row(i)("item")

DataReader

label.text = dr("item")

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2
use commandObj.ExecuteScalar() to return the single value ...
(i'll use generic objects - you use the proper ones that correspond with
your data provider)

dim conn as new Connection(strConnString)
dim cmd as new Command()

conn.open()
cmd.connection = conn
cmd.comandtext = "select field1 from table1 where pkfield = value"
dim strField1Value as string = cstr(cmd.executeScalar())
conn.close()

the use it ....
control.Text = strField1Value
or
response.write(strField1Value)

if you aren't using ASP.NET ... this is the wrong forum ....

"Josh" <an*******@microsoft.com> wrote in message
news:b7****************************@phx.gbl...
This I'm sure is a silly question, but I am pulling one
field from one particular record and for the life of me
can't figure out how to display/manipulate it. Every
single tutorial or code sample relating asp.net and
database access uses a datagrid, which doesn't help me
here. Can someone please direct me to a resource that
shows the asp.net equivalent of the below code?

strSQL = "SELECT field FROM table WHERE id=1"

Set objRS = objConn.Execute(strSQL)

Response.Write objRS("field")

Thanks,

Josh

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robin S. | last post by:
I tried to ask this question several days ago, but I didn't explain my application correctly. Basically I want to have one record from table "A" and I want to display, say, 5 records from table...
13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
5
by: Harlequin | last post by:
Hi there, I'm something of a newcomer to MS Access so it's more than likely that my question is extremely elementary. I have a form whose record source is a single table in my database. It's...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.