Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataAdapter.InsertCommand
Message
De
23/09/2003 10:21:40
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
DataAdapter.InsertCommand
Divers
Thread ID:
00831482
Message ID:
00831482
Vues:
46
I am having trouble creating an InsertCommand to insert a record into a VFP table. However, my DeleteCommand and UpdateCommand work just fine.

Here is my insert method:
string lc_emkey = "TEST1";
string lc_ConnectionString = "Provider=VFPOLEDB.1;Data Source=C:\\apps\\;Mode=ReadWrite|Share Deny None";
string lc_sql = "INSERT INTO employee (em_key) VALUES ('" + lc_emkey + "') ";
OleDbConnection conn = new OleDbConnection(lc_ConnectionString);
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand(lc_sql, conn);
da.SelectCommand = cmd;
da.InsertCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "employee");
The following is my DeleteCommand and UpdateCommand. These 2 command work just fine. However, my InsertCommand above does not work.
///UpdateCommand
string lc_emkey = "JERRY";
string lc_depart = "IS";
string lc_ConnectionString = "Provider=VFPOLEDB.1;Data Source=C:\\apps\\;Mode=ReadWrite|Share Deny None";
string lc_sql = "UPDATE employee SET em_depart = '" + lc_depart + "' " +
				"WHERE em_key = '" + lc_emkey + "'";
OleDbConnection conn = new OleDbConnection(lc_ConnectionString);
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand(lc_sql, conn);
da.SelectCommand = cmd;
da.UpdateCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "employee");

//DeleteCommand
string lc_emkey = "JERRYT";
string lc_ConnectionString = "Provider=VFPOLEDB.1;Data Source=C:\\apps\\;Mode=ReadWrite|Share Deny None";
OleDbConnection conn = new OleDbConnection(lc_ConnectionString);
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand("DELETE FROM employee WHERE em_key = '" + lc_emkey + "'", conn);
da.SelectCommand = cmd;
da.DeleteCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "employee");
What am I doing wrong?

Thanks,

Jerry
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform