Dataset items to variables !!! URGENT!!!

  • Thread starter Michael Persaud
  • Start date
M

Michael Persaud

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).ToString

UCity = ds.Tables("ContactDetails").Rows(1).Item(0).ToString
...............................
 
E

Eric Cherng

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top