Hello everyone,
I have three different tables. Customer, Product and Orderline. Now, I want to find how to retrieve the information from a product object in order to insert that data into the orderline. My product object has pName as a key, and imagePath and pPrice as attributes. But all I want - is to get the price, to be returned as a decimal value.
This is what I've done so far and it's not working:
I'm having the problem with the last line. I'm getting the correct product name - finding it's key, but how do I get the price of that product?
I've tried to modify that line heaps of times now, and I still just cant figure it out.
I've tried drRow.Item("pPrice") - that didn't give me any errors, though at the same time, it didn't add nothing to the orderline table. Because I was guessing that an empty object of product is being created. But how to avoid this?
Please help.
Thank you.
Widunder.
I have three different tables. Customer, Product and Orderline. Now, I want to find how to retrieve the information from a product object in order to insert that data into the orderline. My product object has pName as a key, and imagePath and pPrice as attributes. But all I want - is to get the price, to be returned as a decimal value.
This is what I've done so far and it's not working:
Code:
Public Function priceLookUp(ByVal pName As String)
Dim SQL As String = "select pPrice from product where pName = '" & pName & "'"
Dim dtProducts As DataTable = myData.getData(SQL)
Dim colProducts As Collection = New Collection
Dim objProduct As Product
Dim drRow As DataRow
For Each drRow In dtProducts.Rows
objProduct = New Product 'empty object being created?
objProduct.ProductPrice = drRow.Item("pPrice")
If colProducts.Contains(pName) = True Then
objProduct = colProducts("ProductName")
Else
End If
Next
Return colProducts("pPrice") 'this line is the one that I have problem with
End Function
I've tried to modify that line heaps of times now, and I still just cant figure it out.
I've tried drRow.Item("pPrice") - that didn't give me any errors, though at the same time, it didn't add nothing to the orderline table. Because I was guessing that an empty object of product is being created. But how to avoid this?
Please help.
Thank you.
Widunder.