Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dataset items to variables !!! URGENT!!!

Reply
Thread Tools

Dataset items to variables !!! URGENT!!!

 
 
Michael Persaud
Guest
Posts: n/a
 
      10-05-2004
Hi All,
I am trying to write the contents of a dataset to variables that i have
declared as string types.

I cannot seem to get it right to assign the field values to the variables

Pls Help
Thanks
MP

Sub getuserDetails()
Dim str As String = "Select Address,City,Telephone,Alternatetele
from ContactDetails where userid=" & LabelUserID.Text
Dim cmdText As New SqlCommand(str, Conn)
Dim ds As New DataSet
Dim da As SqlDataAdapter = New SqlDataAdapter(cmdText)
Conn.Open()
da.Fill(ds, "ContactDetails")

Conn.Close()

UAddress = ds.Tables("ContactDetails").Rows(1).Item(0).ToStri ng

UCity = ds.Tables("ContactDetails").Rows(1).Item(0).ToStri ng
...............................


 
Reply With Quote
 
 
 
 
Eric Cherng
Guest
Posts: n/a
 
      10-05-2004
Are you sure there are items returned? Are there any exceptions thrown?

Btw, I'm assuming you know that the SQL code you posted is susceptible to
SQL injection attack. I hope you just did that to show the code and isn't
the actual code.

--
Eric Cherng
MCP, MCDBA, MCSD
http://echerng.com


"Michael Persaud" <> wrote in message
news:...
> Hi All,
> I am trying to write the contents of a dataset to variables that i have
> declared as string types.
>
> I cannot seem to get it right to assign the field values to the variables
>
> Pls Help
> Thanks
> MP
>
> Sub getuserDetails()
> Dim str As String = "Select Address,City,Telephone,Alternatetele
> from ContactDetails where userid=" & LabelUserID.Text
> Dim cmdText As New SqlCommand(str, Conn)
> Dim ds As New DataSet
> Dim da As SqlDataAdapter = New SqlDataAdapter(cmdText)
> Conn.Open()
> da.Fill(ds, "ContactDetails")
>
> Conn.Close()
>
> UAddress = ds.Tables("ContactDetails").Rows(1).Item(0).ToStri ng
>
> UCity = ds.Tables("ContactDetails").Rows(1).Item(0).ToStri ng
> ..............................
>
>



 
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
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Removing Menu Items and Child Menu Items Larry Bud ASP .Net 13 01-07-2008 02:12 PM
Looping through CheckBoxList items doesn't pick up selected ones when items were disabled Bart Van Hemelen ASP .Net 2 09-04-2006 08:35 AM
Items in Outbox not moving to Sent Items Ben Lord Computer Support 0 10-23-2003 08:47 AM
grouping items among a list according to items subtag value Gilles Kuhn XML 0 09-15-2003 12:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57