dumb database question

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
ok, i've got a simple two table ms access database, most of the primary table is displayed in labels but some parts of it (three feilds actually) contain balances of which are calculated by the program, instead of binding them to labels or textboxs i want them to be stored in variables, how do i do this? and when i update the dataset, those variable values go back to the database as well, how do i do that too?
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
pretty much i jes want to bind a variable to a feild in a database like you would a label or a textbox is all
 

bloukewer

Well-known member
Joined
Jul 2, 2004
Messages
88
Programming Experience
3-5
Yeah, I would also like to know. Dumb question, but valid, none-the-less.
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
well i found a way around it useing a label, tis a bitch doing it this way but it works
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
Since you didn't specify, I assume you're using a dataTable to hold the data from the dataBase :).

If so, you can create a new dataColumn, set it's Expression property to a valid expression, and add the column to the dataTable. Then you could bind the text property of a textbox or label to the new column. You can also Update the dataBase with the new dataSet.

Here's sample code for creating the new column. The example dataTable has two columns (fields) named Number1 and Number2. The new column is the addition of these two fields. The dataTable is named dt and the textbox that is bound to the new column is named txtAddition.
VB.NET:
Dim dc As DataColumn
dc = New DataColumn("Addition", GetType(System.Int32))
dc.Expression = "Number1 + Number2"
dt.Columns.Add(dc)
txtAddition.DataBindings.Add(New Binding("Text", dt, "Addition"))
Please try to use more descriptive subject lines. Thanks :).
 
Top Bottom