Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Displaying single record

Reply
Thread Tools

Displaying single record

 
 
Josh
Guest
Posts: n/a
 
      08-03-2004
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
 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      08-03-2004
"Josh" <> wrote in news:b7c901c47986$2fa35b70
$:

> 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 ()
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
 
 
 
Thomas Dodds
Guest
Posts: n/a
 
      08-03-2004
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" <> wrote in message
news:b7c901c47986$2fa35b70$...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating a Record using a current record MRW ASP .Net 0 02-11-2008 06:58 PM
IP Address, MX Record, A Record Question K.J. 44 Cisco 2 09-06-2006 05:14 PM
You cannot add or change a record because a related record is required in table 'lok" André ASP .Net 0 06-25-2006 01:30 PM
Retrieving Record Key while creating the record. =?Utf-8?B?SnVzdGlu?= ASP .Net 4 10-05-2004 08:11 PM
" Invalid Disk Table in Boot Record - Boot Record could not be repaired " reply@newsgroup.please Computer Support 2 12-01-2003 05:37 AM



Advertisments