xxxsenatorxxx
دوشنبه 14 فروردین 1391, 00:40 صبح
ا سلام و خسته نباشید
در فرم add با چند تکست باکس و دیتا بیس اکسس میخواهیم پیغام بده اطلاعات وارد شده قبلا ثبت شده یعنی پیغام تکراری بودن اطلاعات رو بده
چندتا روش گشتم پیدا کردم ولی یا کار نمیکنه یا خطا میده
یه کمکی بکنید. یه راه خوب که کار کنه بگید.ممنون
try
{
OleDbException ex;
if (ex.ErrorCode == -2147467259)
{
Program.HandleException(ex, false, null);
MessageBox.Show("اطلاعات این فرد قبلا ثبت شده است");
}
else
{
Program.HandleException(ex, true, null);
}
}
catch
{
OleDbCommand dps = new OleDbCommand();
dps.CommandText = "select post,name,family,number,comment from DBA where code= " + comboBox1.Text + " and name = " + textBox2.Text + " and family = " + textBox3.Text + " and number = " + textBox4.Text + " and comment = " + textBox5.Text + " ";
dps.Parameters.Add(new OleDbParameter("number", textBox4.Text));
dps.Connection = oleDbConnection1;
d = dps.ExecuteNonQuery();
if (d > 0)
MessageBox.Show(" تکراری");
int tekrari = 0; oleDbConnection1.Open();
oleDbDataAdapter1.SelectCommand.CommandText = "select code,name,family,number,comment from DBA where code = " + comboBox1.Text + " and name = " + textBox2.Text + " and family = " + textBox3.Text + " and number = " + textBox4.Text + " and comment = " + textBox5.Text + " ";
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();
tekrari = oleDbDataAdapter1.
if(tekrari != 0)
{
}
در فرم add با چند تکست باکس و دیتا بیس اکسس میخواهیم پیغام بده اطلاعات وارد شده قبلا ثبت شده یعنی پیغام تکراری بودن اطلاعات رو بده
چندتا روش گشتم پیدا کردم ولی یا کار نمیکنه یا خطا میده
یه کمکی بکنید. یه راه خوب که کار کنه بگید.ممنون
try
{
OleDbException ex;
if (ex.ErrorCode == -2147467259)
{
Program.HandleException(ex, false, null);
MessageBox.Show("اطلاعات این فرد قبلا ثبت شده است");
}
else
{
Program.HandleException(ex, true, null);
}
}
catch
{
OleDbCommand dps = new OleDbCommand();
dps.CommandText = "select post,name,family,number,comment from DBA where code= " + comboBox1.Text + " and name = " + textBox2.Text + " and family = " + textBox3.Text + " and number = " + textBox4.Text + " and comment = " + textBox5.Text + " ";
dps.Parameters.Add(new OleDbParameter("number", textBox4.Text));
dps.Connection = oleDbConnection1;
d = dps.ExecuteNonQuery();
if (d > 0)
MessageBox.Show(" تکراری");
int tekrari = 0; oleDbConnection1.Open();
oleDbDataAdapter1.SelectCommand.CommandText = "select code,name,family,number,comment from DBA where code = " + comboBox1.Text + " and name = " + textBox2.Text + " and family = " + textBox3.Text + " and number = " + textBox4.Text + " and comment = " + textBox5.Text + " ";
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();
tekrari = oleDbDataAdapter1.
if(tekrari != 0)
{
}