Reputation: 155
I'm trying to show a messagebox with the users first name from a dataset but I keep getting an integer returned.
Below is the code I'm currently using to get a 1 returned. The datatable only contains 1 column named "Name" and it is set as a system.string if that helps.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show(FirstNameTableAdapter.Fill(DsUsers.FirstNameTable, Environment.UserName), "User")
End Sub
I just feel like it's something very easy I'm missing.
Upvotes: 0
Views: 461
Reputation: 3271
The function call of FirstNameTableAdapter.Fill(DsUsers.FirstNameTable, Environment.UserName)
will fill the DataTable FirstNameTable
with the result of its associated CommandText. It's return value will be number of rows it has loaded.
What I think you want to be doing is calling this line separately
FirstNameTableAdapter.Fill(DsUsers.FirstNameTable, Environment.UserName)
And then calling the message box
MessageBox.Show(DsUsers.FirstNameTable.Rows(0)("Name"), "User")
Upvotes: 2