TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sawass sawass
NA
36
23.6k
Exception database
Jun 8 2011 10:11 PM
Hi,
I
'm
still in the same
problem.
I have
an
error
when
I
edit a
user
in the database.An
error
in
this line
:
" cmd1.ExecuteNonQuery();"
the exception is long:
System.Data.Odbc.OdbcException (0x80131937): ERROR [07002] [Microsoft][Pilote ODBC Microsoft Access]Champ COUNT incorrect.
here is my code:
private void bt_valider_Click(object sender, System.EventArgs e)
{
OdbcConnection cn = new OdbcConnection("DSN=cp3");
try
{
cn.Open();
}
catch
{
MessageBox.Show("Failed to connect to data source");
}
finally
{
OdbcCommand comm;
comm = new OdbcCommand("select * from utilisateur where login=?", cn);
objParameter = comm.Parameters.AddWithValue("login", old_login.Text);
// comm = new OdbcCommand("select * from utilisateur where login='@L'I", cn);
// comm.Parameters.Add("@LI", old_login.Text);
OdbcDataReader rs;
try
{
rs = comm.ExecuteReader();
if (rs.Read())
{
if (rs.GetString(1) == old_pass.Text)
{
rs.Close();
OdbcParameter objParameter2 = new OdbcParameter();
OdbcCommand cmd1 = new OdbcCommand("update utilisateur set login=?,mot_de_passe=?,niveau=?, where login=?", cn);
objParameter2= cmd1.Parameters.AddWithValue("login", new_login.Text);
objParameter2 = cmd1.Parameters.AddWithValue("mot_de_passe", new_pass.Text);
if (new_type.SelectedItem.ToString() == "")
objParameter2 = cmd1.Parameters.AddWithValue("type", "u");
if (new_type.SelectedItem.ToString() == "Administrateur")
objParameter2 = cmd1.Parameters.AddWithValue("type", "a");
if (new_type.SelectedItem.ToString() == "utilisateur")
objParameter2 = cmd1.Parameters.AddWithValue("type", "u");
objParameter2 = cmd1.Parameters.AddWithValue("", old_login.Text);
cmd1.ExecuteNonQuery();
MessageBox.Show(this, "Invalid login or password ", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
old_login.Text = "";
old_pass.Text = "";
new_login.Text = "";
new_pass.Text = "";
}
else
MessageBox.Show(this, "Invalid login or password ", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show(this, "User does not exist ", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception eo)
{
MessageBox.Show(this, "Error System", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
old_login.Text = eo.ToString();
}
}
cn.Close();
}
I need
help
and
it is
important to me
.
I
planted.Thanks in advance for your help.
Reply
Answers (
4
)
Labelling a slider
CREATE DATABASE permission denied in database master