DataAdapters/DataSets

  • Thread starter Thread starter Adam Clauss
  • Start date Start date
A

Adam Clauss

Alright, as much as I've done CSharp, I've done very little with databases with it. So I'm just kind of messing around with,
learning how it works.
I am using the ADO.NET adapter provided with MySQL in a very simple web application.
I have the connection, data adapter, and typed datasets created. In response to a button submit, I perform the following:

accountsDataAdapter.Fill(accountsDS1);
Label_Accounts.Text = accountsDS1.accounts.Count.ToString();

The label gets set to 0 - even though there ARE accounts present in the table. In fact, if I instead do:
Label_Accounts.Text = accountsDataAdapter.Fill(accountsDS1).ToString();

I correctly return 46.

Its possible its a problem in the custom data provider, but I wanted to be sure I was using it correctly first :)

Thanks!
 
Adam Clauss said:
Alright, as much as I've done CSharp, I've done very little with databases with it. So I'm just kind of messing around with,
learning how it works.
I am using the ADO.NET adapter provided with MySQL in a very simple web application.
I have the connection, data adapter, and typed datasets created. In response to a button submit, I perform the following:

accountsDataAdapter.Fill(accountsDS1);
Label_Accounts.Text = accountsDS1.accounts.Count.ToString();

The label gets set to 0 - even though there ARE accounts present in the table. In fact, if I instead do:
Label_Accounts.Text = accountsDataAdapter.Fill(accountsDS1).ToString();

I correctly return 46.

Its possible its a problem in the custom data provider, but I wanted to be sure I was using it correctly first :)

I'm a little confused by the syntax in the following lines:

accountsDataAdapter.Fill(accountsDS1);
Label_Accounts.Text = accountsDS1.accounts.Count.ToString();

Since a DataSet is a collection of DataTables, I have typically seen the Fill method used with two parameters, dataset comma tablename. For example:

accountsDataAdapter.Fill(accountsDS1, "Accounts"); // or whatever table is named

Also, what is the 'accounts' property of accountsDS1? Shouldn't that be as follows:

Label_Accounts.Text = accountsDS1.Tables["Accounts"].Rows.Count.ToString();

I don't know if these are actual syntax errors or a lack of understanding on my part.

- carl
 
I am not very use to with Typed Dataset Syntax, but I think accounts is your
Table, when you call ToString on DataAdapter's Fill method, it returns
number of rows in your table, try checking
accountsDS1.accounts.rows.count.tostring(). Pl. sorry abt the Typed DS
syntax, what I mean try to count the number of rows in Rows collection.

Adam Clauss said:
Alright, as much as I've done CSharp, I've done very little with databases
with it. So I'm just kind of messing around with,
learning how it works.
I am using the ADO.NET adapter provided with MySQL in a very simple web application.
I have the connection, data adapter, and typed datasets created. In
response to a button submit, I perform the following:
accountsDataAdapter.Fill(accountsDS1);
Label_Accounts.Text = accountsDS1.accounts.Count.ToString();

The label gets set to 0 - even though there ARE accounts present in the
table. In fact, if I instead do:
Label_Accounts.Text = accountsDataAdapter.Fill(accountsDS1).ToString();

I correctly return 46.

Its possible its a problem in the custom data provider, but I wanted to be
sure I was using it correctly first :)
 
Back
Top