Hello. VB Express 2010.
The following fragment is supposed to display the data from a DataSet following inserting of a new record, but doesn't work.
strSql = "SELECT StaffID, FirstName, LastName FROM dbo.Staff WHERE StaffID = " & CInt(txtID.Text)
da = New SqlDataAdapter(strSql, cnn)
da.Fill(ds, "NewMember")
txtOutput.Text = ds.ToString
I also tried ds.Tables("NewMember").ToString.
The new staff record is inserted correctly using the ID number in the txtID textbox.
How can I output the data from a DataSet to a TextBox? Thanks, Andy.
Display DataSet data
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Display DataSet data
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 77253
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Display DataSet data
I don't know anything about VB Express 2010, but aren't you supposed to specify a table, row and column?
txtOutput.Text = ds.Tables(0).Rows(0).Item(0).ToString
txtOutput.Text = ds.Tables(0).Rows(0).Item(0).ToString
Regards,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Display DataSet data
Hello.
That works fine. I was following an example from Teach Yourself SQL Server Express by Alison Balter. It's a disappointing book as it has lots of
coding mistakes and is poorly organised. Thanks, Andy.
That works fine. I was following an example from Teach Yourself SQL Server Express by Alison Balter. It's a disappointing book as it has lots of
coding mistakes and is poorly organised. Thanks, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.