1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
string c = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"dbart.accdb\"";
OleDbConnection con = new OleDbConnection(c);
con.Open();
OleDbCommand cmd = new OleDbCommand(string.Format("insert into client (nomclient, prenomclient,telclient) values('{0}', '{1}', '{2}'); SELECT CAST(SCOPE_IDENTITY() AS INT)", nomclient.Text, prenomclient.Text, telclient.Text), con);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "client");
int idP = (int)cmd.ExecuteScalar();
MessageBox.Show("idP=" + idP);
con.Close();
Form1 f = new Form1();
f.Show(); |
Partager