Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't delete row
Message
De
10/04/2007 13:13:52
 
 
À
10/04/2007 12:56:45
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01214017
Message ID:
01214021
Vues:
15
The CommandBuilder is not creating the commands. The DeleteCommand = null. I have specified the primary key and am retrieving it in the Select statement.

So, the next question is, why isn't the CommandBuilder working?

>I'm trying to delete a row in a datatable. I've followed examples from three different places, but I still get the error "Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information."
>
>Here's the scaled down code:
>
>SqlConnection conn;
>SqlDataAdapter daAllData;
>DataSet dsAllData;
>DataRelation relGroupsFeeds;
>
>conn = new SqlConnection(@"Server=(local); Integrated Security = true; Database = FeedMe");
>daAllData = new SqlDataAdapter("SELECT GroupPK, Description FROM Groups", conn);
>
>SqlCommandBuilder commandBuilder = new SqlCommandBuilder(daAllData);
>
>dsAllData = new DataSet();
>daAllData.Fill(dsAllData, "Groups");
>
>// I can leave these three lines in or out. I get the same result.
>DataColumn[] keys = new DataColumn[1];
>keys[0] = dsAllData.Tables["Groups"].Columns["GroupPK"];
>dsAllData.Tables["Groups"].PrimaryKey = keys;
>
>string ID = "4";
>int groupPK = int.Parse(ID);
>DataRow row = dsAllData.Tables["Groups"].Rows.Find(groupPK);
>row.Delete();
>
>// Error occurs on Update()
>daAllData.Update(dsAllData, "Groups");
>conn.Close();
>
>Any suggestions for what to look at?
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform