[C#] Problème requête update via OdbcDataAdpter
Bonjour !
J'ai une erreur lorsque j'essaie de faire un update sur une table via OdbcDataAdapter.
Voilà mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public void IAmConnected()
{
DataSet oDataSet;
OdbcDataAdapter oDataAdapter;
BD bd = new BD();
OdbcConnection con = bd.Connect();
oDataAdapter = new OdbcDataAdapter("select * from connected", con);
oDataSet = new DataSet("Connected");
oDataAdapter.Fill(oDataSet, "Connected");
oDataAdapter.InsertCommand = new OdbcCommand("INSERT INTO connected(LOGIN) Values(@LOGIN)", con);
oDataAdapter.InsertCommand.Parameters.Add("@LOGIN", OdbcType.NVarChar,15, "LOGIN");
DataRow oDataRow;
oDataRow = oDataSet.Tables["Connected"].NewRow();
oDataRow["LOGIN"] = HttpContext.Current.Session["ID"];
oDataSet.Tables["Connected"].Rows.Add(oDataRow);
try
{
oDataAdapter.Update(oDataSet, "Connected");
}
catch (Exception e)
{
Response.Write(e.Message.ToString());
}
} |
Dans un premier temps, je récupère le contenu de ma table dans un dataset.
Puis j'ajoute une ligne à mon dataset
Puis j'insère une commande à odbcdataadapter (ça je n'ai pas compris)
Puis update.
J'ai l'erreur suivant:
Code:
1 2
|
ERROR [HYT00] Le champ 'LOGIN' ne peut être vide (null) |
J'ai vérifier et
Citation:
HttpContext.Current.Session["ID"]
n'est pas vide...
Qu'est ce qui ne va pas dans ce code ??
Merci pour vos réponses !!