Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataAdapter.Fill() method
Message
 
À
15/02/2006 10:21:21
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 2.0
Database:
MS SQL Server
Divers
Thread ID:
01096461
Message ID:
01096503
Vues:
11
Thanks Bonnie. U da woman! Just what I needed.

Einar
>Check out the MissingSchemaAction property of the DataAdapter.
>
>~~Bonnie
>
>
>
>>Again something works differently than how I expected it to work.
>>I have a table with 3 fields (field1, field2 and field3). I created a typed dataset from that table, but I removed field3 so the dataset only has 2 fields (field1 and field2).
>>I run the following code:
>>
>>DataSet1 ds = new DataSet1();
>>MessageBox.Show("Coulumns.Count: " + ds.Table2.Columns.Count.ToString(), "before");
>>
>>SqlDataAdapter adapter = new SqlDataAdapter();
>>adapter.SelectCommand = new SqlCommand("SELECT field1, field2, field3 FROM Table2", new SqlConnection("Data Source=localhost;Initial Catalog=Test;Integrated Security=SSPI;"));
>>adapter.Fill(ds, ds.Table2.TableName);
>>
>>MessageBox.Show("Coulumns.Count: " + ds.Table2.Columns.Count.ToString(), "after");
>>
>>
>>The first msgbox (with title before) displays a column count of 2 which is what I expect, but the 2nd msgbox (with title after) displays a column count of 3 which is not really what I expect.
>>
>>I understand why field3 is in my dataset after the fill (because it is included in the SELECT statement), but I am hoping that there is a way to prevent the structure of the dataset to be changed as a result of the Fill().
>>
>>Einar
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform