• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Setting a string variable as a dataset field value

How do I assign a string variable to a dataset field value. I am attaching to a SQL server, so I am using a SQLConnection, SQLDataAdapter, and a DataSet. Currently I am having to bind the field to a hidden text box. I really do not like this. Any ideas?
0
originsone
Asked:
originsone
  • 3
  • 2
  • 2
2 Solutions
 
jrandallsextonCommented:
Do you mean how do you get the values out of the dataset and put it into the variable?
0
 
DotNetLover_BaanCommented:
The concept of "Data Binding" is ONLY for controls. In broader sense, Control is nothing but a variable.
0
 
originsoneAuthor Commented:
Yes jrandallsexton. A variable that is a string.

DotNetLover  Has this changed since VB6? I thought you could assign data to a variable in 6. something like this.

Dim a as String
a = rsConnection!field

Please correct me if I am wrong.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jrandallsextonCommented:
Do you simply want to iterate the dataset and get the values out?
If so ...

        Dim dr As DataRow
            For Each dr In myDataSet.Tables(0).Rows
                If (condition) Then
                    someVariable = dr.Item(0).ToString
                    someVariable2 = dr.Item(1).ToString
                End If
            Next
0
 
DotNetLover_BaanCommented:
originsone ,
this is not binding.... what you are thinking... this is just assigning a field value to a variable. "BINDING" is different, from just assigning a value.
0
 
jrandallsextonCommented:
Baan is correct.  That is not binding - neither is what I did.

I simply am assigning the values from the dataset to whatever variables you need.
0
 
originsoneAuthor Commented:
Thanks! This is exactly the information i need. This is why I pay $10 a month.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now