only 1 record

(I posted this in the Windows Forms Data Binding section, and they directed me somewhere else, and somewhere else directed me here.)

I have VS 2003. I'm using VB.NET to connect to a SQL database. When I fill the dataset, I only get 1 record returned.

I went thru the walkthrough in the Samples, and the connection to the Pubs database works fine. I did the same thing to a live database, and only get the one record returned, no matter what table I try to read.

The only difference I can see is that in the Pubs database, the author_id field has a data type of ID (VARCHAR). My live data has a key field with a data type of Varchar.

The code is pretty much straight out of the walkthrough sample, to the point that it's almost trivial.

Here's the Click_Show snippet:
Me.DataSet_FI_11.Clear()
Me.SqlDataAdapter1.Fill(DataSet_FI_11)
Call ShowPosition()

I used the wizard to set up the data adapter. Here's the Select command:
SELECT top 10 * FROM FI

I've modified the Select command several different ways, including having a where clause, not using the top 10 statement, and specifying field names instead of using the '*'. I've also re-created the form using a different table from the same database.

The only controls on the form are the Show, Prev, and Next buttons, the Position text box, and 3 text boxes bound to fields in the data set. The 3 text boxes display data as they should, and if I add a WHERE clause to the Select command, it will return a different record, but never more than 1.

I've also tried it using an OLEdbAdapter instead of the SQL Adapter, and still only get 1 record.

Any idea why I'm only getting 1 record?

Thanks,
Andy

[1907 byte] By [AndyDavis] at [2007-12-16]
# 1
Andy,

Can you post the query, table's create table statement, and if there is anything special with the data? Once I have that we can try to reproduce this.

Thanks,

Carl Perry
Program Manager ADO.NET
cperry@microsoft.com

CarlPerry-Microsoft at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
Hey Carl, Thanks for the reply.

The message you're responding to is a couple of months old. I went ahead and contacted MS and got the paid support and got it solved.

It turns out that the dataset was actually returning all the records, but I couldn't see them. For it to work, I needed to put the table name after the dataset name. I had

Me.BindingContext(DS_FIs1)

But when I changed it to

Me.BindingContext(DS_FIs1, "FI")

it worked. According to the samples, the first way should have been acceptable, but it didn't work for me until I added the table name.

Anyway, problem solved. Thanks again for the reply.

ALD

AndyDavis at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified