Problem with a (probably) easy solution

liquidspaces

Well-known member
Joined
Nov 19, 2002
Messages
74
Location
Richmond, VA
Ok, this is what Im doing. On the Form1_Load event, Im writing the string "TEMP" to the "SHIP_FROM" field in the database. Im doing this so the autonumber will be ready and waiting. This part works fine:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objRow As DataRow
objRow = DataSet31.Tables("Shipping").NewRow
objRow.Item("SHIP_FROM") = "TEMP"
DataSet31.Tables("Shipping").Rows.Add(objRow)

OleDbDataAdapter2.Update(DataSet31)

End Sub


Its this part that I believe Im having problems with. I need to get the value of the "BILL_OF_LADING_NUM" field, but instead the ROW NUMBER is returned.

Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
Dim intBOLN As Integer
intBOLN = OleDbDataAdapter2.Fill(DataSet31, "BILL_OF_LADING_NUM")
lblBOLN.Text = intBOLN
End Sub


The SQL statement included in OleDbDataAdapter2 is as follows:

SELECT SHIP_FROM, BILL_OF_LADING_NUM FROM Shipping WHERE (SHIP_FROM = TEMP)

After I get the autonumber, "TEMP" will be written over with whatever the real value may be.

There must be a simple solution. All I need is to assign the value of BILL_OF_LADING_NUM to lblBOLN.

Thanks,
Kevin
 
Havent played with databases in .NET yet, but this SQL statement seems rather odd to me...

SELECT SHIP_FROM, BILL_OF_LADING_NUM FROM Shipping WHERE (SHIP_FROM = TEMP)

You try ...

SELECT SHIP_FROM, BILL_OF_LOADING_NUM FROM Shipping WHERE SHIP_FROM = TEMP

? Probably wont change anything but who knows these days.

Other then that the only thing I can think of is that the .Fill method isnt working as you intended it to.



Edit: I looked up .Fill in the object browser and this is what it describes it as; Adds or refreshes rows in a System.Data.DataTable to match those in an ADO Recordset or Record object using the specified System.Data.DataTable and ADO objects. Im pretty sure thats not what you are intending to do. It returns an Integer which is the number of rows successfully refreshed.

 
Last edited by a moderator:
wyrd:
Thanks for your suggestion. I gave it a try but still got the same result: The row number.

If you have any other ideas, please feel free to pass them along.
Thanks,
Kevin
 
Just editted my post above.. I looked up .Fill in the object browser and its not working the way you thought it would. (look at previous post for explanation). Since I dont know databases in .NET I have no idea what the actual method is for retrieving a value in a database. Crack open the object browser and roam around Im sure youll find what youre looking for.
 
Ahhh...that explains it, then. I thought fill was putting the values of the row into the adapter. Ill have to do some searching to figure out how to do this. I just started VB 6 days ago, so my knowledge is very limited. Im learning a lot though through stuff like this!

Thanks again,
Kevin
 
Back
Top