Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert, update thru dataset
Message
De
30/10/2009 13:07:05
 
 
À
30/10/2009 10:20:32
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 3.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MySQL
Application:
Web
Divers
Thread ID:
01432362
Message ID:
01432392
Vues:
34
>Hello All,
>
>I am trying to insert, update records thru dataset..,but it doesnot work ...
>please help.
>
>
>//show data
>
>cn = new MySqlConnection(mmyclass1.readMySqlConnString);
>cn.Open();
>ds = new DataSet();
>string msqlselect = "select * from da where hostid = " + mhostid + " and ano = '" + pano + "'";
>da = new MySqlDataAdapter(msqlselect, cn);
>da.SelectCommand.CommandText = msqlselect;
>ds.Clear();
>da.Fill(this.ds);
>daTable = this.ds.Tables[0];
>mmyclass1.BindField(this.textBox1, "Text", daTable, "ades");
>mmyclass1.BindField(this.checkBox1, "Checked", daTable, "hda");
>mmyclass1.BindField(this.comboBox3, "SelectedIndex", daTable, "atype");
>mmyclass1.BindField(this.textBox2, "Text", daTable, "adelay");
>
>//save
>
>if (cn.State == ConnectionState.Closed)
>{
>cn = new MySqlConnection(mmyclass1.readMySqlConnString);
>cn.Open();
>}
>MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
>cb.ReturnGeneratedIdentifiers = false;
>cb.GetInsertCommand();
>cb.GetUpdateCommand();
>da.Update(daTable);
>ds.AcceptChanges();
>
>
I'm rusty on this but shouldn't you be setting the commands on the DataAdapter rather than the CommandBuilder?
Does this help:http://www.devart.com/forums/viewtopic.php?p=44082&sid=602f8e78cbd05415329315dfcabebcca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform