Question about storing the value of a record..

eaohen

New member
Joined
Oct 19, 2009
Messages
2
Programming Experience
1-3
Hello,

I am new to programming and I am using Dreamweaver cs4 and Visual web studios to develop applications...

I have a question, and it may seem simple but It has me completely confused.


Basically below is the code I am using, I am trying to store variables from user input, then use these variables to generate query and return a numeric value from an Access database.

I can display query the database fine, my issue is that I cannot get the value to be stored to a variable to compute cost.

I basically need to understand how to select a "Cost" Column from an access database based on a identifer then store that cost as a variable and then compute cost..

Can anyone provide me with a link to a tutorial or help me understand what I need to store a specific value from a recorD?


pumpsel = Pumpselection.SelectedItem.Text
motorsel = Motorselection.SelectedItem.Text
hpsel = HorsepowerSelection.SelectedItem.Text
startersel = Starterselection.SelectedItem.Text
wiringsel = Wiringselection.SelectedItem.Text


dim cost

' Define a connection object
Dim dbConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=\\deco2\Testing\FinaDB.mdb")

' Create a data adapter to retrieve records from db
Dim strSELECT As String = "SELECT * FROM Belt"
Dim daUsers As New OleDbDataAdapter(strSELECT, dbConn)
Dim dsUsers As New DataSet("Employee")

' Fill the dataset
daUsers.Fill(dsUsers)

' Go through the records and print them using the mapped names
Dim r As DataRow
For Each r In dsUsers.Tables(0).Rows
Cost = Cstr(r("Cost"))
Next




lbl1.text = pumpsel
 
Can you:

1) use CODE tags (read this: Visual Basic .NET Forums - BB Code List)
2) after putting your code in CODE tags, go through it line by line and write a comment as to what you think each line is for

By the last part I don't mean:

'declare a variable called cost
Dim cost as Integer

(I know what a Dim statement does :) ), I mean:

'variable to hold a running cost; we'll add all costs for all items into here later
Dim cost as Integer
 
Back
Top