نمایش نتایج 1 تا 6 از 6

نام تاپیک: خطا در درج

  1. #1
    کاربر تازه وارد
    تاریخ عضویت
    فروردین 1387
    پست
    74

    خطا در درج

    سلام خدمت دوستان
    بعد از اینکه دکمه در ج را می زنم خطا زیر رو می ده البته هیچ یک از پارامترهای من تکراری نیست و چند تا از فیلدهای من از نوع بیت هستند .
    the variable name '@iu@' has already has been declared variable names must unique within a query batch or stored procedure .
    must declare the variable '@nu'

  2. #2

    نقل قول: خطا در درج

    سلام دوست عزیز ،
    مجددا" کد مورد نظر خود را چک کنید ، به احتمال قوی در جایی نام پارامترها Duplicate میشوند ، جهت بررسی بیشتر ، کد خود را قرار دهید ،
    I've just started tweeting!
    @Alireza_Maddah

  3. #3
    کاربر تازه وارد
    تاریخ عضویت
    فروردین 1387
    پست
    74

    نقل قول: خطا در درج


    try
    {

    this.sqlcom.Parameters.Add("@iu", SqlDbType.Int);
    this.sqlcom.Parameters.Add("@n", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@l", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@un", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@p", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@xx", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@v", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@c", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@d", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@eb", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@city", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@o", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@bill", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@expb", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@du", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@cp", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sbr", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sc", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sd", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sv", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sb", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@so", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@edit", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@del", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@insert", SqlDbType.Bit);
    if (this.txtidUser.Text != "")
    this.sqlcom.Parameters[0].Value =int.Parse(this.txtidUser.Text);
    else
    MessageBox.Show("ک§ کں© © ©ں يں©§ کëی§");
    if (this.txtnameUser.Text != "")
    this.sqlcom.Parameters[1].Value = this.txtnameUser.Text;
    else
    MessageBox.Show("ëںê کں© © ©ں يں©§ کëی§");
    if (this.txtlastName.Text != "")
    this.sqlcom.Parameters[2].Value = this.txtlastName.Text;
    else
    MessageBox.Show("ëںê ¦ںëيں§گی کں© © ©ں يں©§ کëی§");
    if (this.txtuserName.Text != "")
    this.sqlcom.Parameters[3].Value = this.txtuserName.Text;
    else
    MessageBox.Show("ëںê کں© ©ی ©ں يں©§ کëی§");
    if (this.txtpassword.Text != "")
    this.sqlcom.Parameters[4].Value = Md5.GetHash(txtpassword.Text);
    else
    MessageBox.Show("©êھ م ي© ©ں يں©§ کëی§");
    if (this.txtretry.Text == "")
    MessageBox.Show("¢ک©ں© ©êھ م ي© ©ں يں©§ کëی§");

    if (this.chken_rec.Checked)
    this.sqlcom.Parameters[5].Value = this.chken_rec.Checked;
    else
    this.sqlcom.Parameters[5].Value = dbnull;
    if (this.chkvehicel.Checked)
    this.sqlcom.Parameters[6].Value = this.chkvehicel.Checked;
    else
    this.sqlcom.Parameters[6].Value = dbnull;
    if (this.chkcargo.Checked)
    this.sqlcom.Parameters[7].Value = this.chkcargo.Checked;
    else
    this.sqlcom.Parameters[7].Value = dbnull;
    if (this.chkdriver.Checked)
    this.sqlcom.Parameters[8].Value = this.chkdriver.Checked;
    else
    this.sqlcom.Parameters[8].Value = dbnull;
    if (this.chkexp_bill.Checked)
    this.sqlcom.Parameters[9].Value = this.chkexp_bill.Checked;
    else
    this.sqlcom.Parameters[9].Value = dbnull;
    if (this.chkcity.Checked)
    this.sqlcom.Parameters[10].Value = this.chkcity.Checked;
    else
    this.sqlcom.Parameters[10].Value = dbnull;
    if (this.chk.Checked)
    this.sqlcom.Parameters[11].Value = this.chk.Checked;
    else
    this.sqlcom.Parameters[11].Value = dbnull;
    if (this.chkbill.Checked)
    this.sqlcom.Parameters[12].Value = this.chkbill.Checked;
    else
    this.sqlcom.Parameters[12].Value = dbnull;
    if (this.chkexp_road_bill.Checked)
    this.sqlcom.Parameters[13].Value = this.chkexp_road_bill.Checked;
    else
    this.sqlcom.Parameters[13].Value = dbnull;
    if (this.chkuser.Checked)
    this.sqlcom.Parameters[14].Value = this.chkuser.Checked;
    else
    this.sqlcom.Parameters[14].Value = dbnull;
    if (this.chkchangepass.Checked)
    this.sqlcom.Parameters[15].Value = this.chkchangepass.Checked;
    else
    this.sqlcom.Parameters[15].Value = dbnull;
    if (this.chksearch_sen_rec.Checked)
    this.sqlcom.Parameters[16].Value = this.chksearch_sen_rec.Checked;
    else
    this.sqlcom.Parameters[16].Value = dbnull;
    if (this.chksearch_cargo.Checked)
    this.sqlcom.Parameters[17].Value = this.chksearch_cargo.Checked;
    else
    this.sqlcom.Parameters[17].Value = dbnull;
    if (this.chksearch_driver.Checked)
    this.sqlcom.Parameters[18].Value = this.chksearch_driver.Checked;
    else
    this.sqlcom.Parameters[18].Value = dbnull;
    if (this.chksearchvehicel.Checked)
    this.sqlcom.Parameters[19].Value = this.chksearchvehicel.Checked;
    else
    this.sqlcom.Parameters[19].Value = dbnull;
    if (this.chksearch_bill.Checked)
    this.sqlcom.Parameters[20].Value = this.chksearch_bill.Checked;
    else
    this.sqlcom.Parameters[20].Value = dbnull;
    if (this.chksearch_order.Checked)
    this.sqlcom.Parameters[21].Value = this.chksearch_order.Checked;
    else
    this.sqlcom.Parameters[21].Value = dbnull;
    if (this.chkedit.Checked)
    this.sqlcom.Parameters[22].Value = this.chkedit.Checked;
    else
    this.sqlcom.Parameters[22].Value = dbnull;
    if (this.chkdel.Checked)
    this.sqlcom.Parameters[23].Value = this.chkdel.Checked;
    else
    this.sqlcom.Parameters[23].Value = dbnull;
    if (this.chkinsert.Checked)
    this.sqlcom.Parameters[24].Value = this.chkinsert.Checked;
    else
    this.sqlcom.Parameters[24].Value = dbnull;

    if (txtpassword.Text != txtretry.Text)
    {
    MessageBox.Show("©êھ م ي© ي¢ک©ں© ©êھ م ي© ©ں ­¥ی¥ يں©§ کëی§", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
    txtpassword.Text = "";
    txtretry.Text = "";
    }
    else
    {
    sqlcom.CommandText = "insert into login( idUser,name,lName,userName,password,sen_rec,vehice l,cargo,driver,exp_bill,city,order1,bill,exproad_b ill,defineuser,changepass,searchsen_rec,search_car go,search_driver,search_vehivel,search_bill,search _order,edit,del,register)values(@iu,@n,@l,@un,@p,@ xx,@v,@c,@d,@eb,@city,@o,@bill,@expb,@du,@cp,@sbr, @sc,@sd,@sv,@sb,@so,@edit,@del,@insert)";
    sqlcon.Open();
    sqlcom.ExecuteNonQuery();
    sqlcon.Close();

    }
    }
    catch (Exception ex)
    {
    sqlcon.Close();
    MessageBox.Show(ex.ToString());
    }
    آخرین ویرایش به وسیله علیرضا مداح : چهارشنبه 19 تیر 1387 در 21:42 عصر دلیل: لطفا" کد را داخل تگ [code] قرار دهید ،/

  4. #4
    منتظر تایید آدرس ایمیل
    تاریخ عضویت
    فروردین 1387
    محل زندگی
    تهران
    پست
    63

    نقل قول: خطا در درج

    حالا چی کار می خوای بکنی

    چون کدت خیلی نا مفهوم

    در ضمن تو برنامه نویسی هرموقع دیدی if ,else و یا حلقه for زیاد استفاده کردی بدون یجای کدت ایراد داره.


    بگو میخوای چه کنی تا راه بهتری معرفی کنم البته اگه بتونم و بلد باشم.

  5. #5
    کاربر دائمی آواتار bachebahal_1363
    تاریخ عضویت
    اسفند 1384
    محل زندگی
    اینترنت
    پست
    336

    نقل قول: خطا در درج

    خواهشا کد هاتون رو تو تگ Code بزارین
    خودتون از کدتون چیزی دستگیرتون میشه ؟

    try
    {

    this.sqlcom.Parameters.Add("@iu", SqlDbType.Int);
    this.sqlcom.Parameters.Add("@n", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@l", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@un", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@p", SqlDbType.NVarChar);
    this.sqlcom.Parameters.Add("@xx", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@v", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@c", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@d", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@eb", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@city", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@o", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@bill", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@expb", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@du", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@cp", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sbr", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sc", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sd", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sv", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@sb", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@so", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@edit", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@del", SqlDbType.Bit);
    this.sqlcom.Parameters.Add("@insert", SqlDbType.Bit);
    if (this.txtidUser.Text != "")
    this.sqlcom.Parameters[0].Value =int.Parse(this.txtidUser.Text);
    else
    MessageBox.Show("ک§ کں© © ©ں يں©§ کëی§");
    if (this.txtnameUser.Text != "")
    this.sqlcom.Parameters[1].Value = this.txtnameUser.Text;
    else
    MessageBox.Show("ëںê کں© © ©ں يں©§ کëی§");
    if (this.txtlastName.Text != "")
    this.sqlcom.Parameters[2].Value = this.txtlastName.Text;
    else
    MessageBox.Show("ëںê ¦ںëيں§گی کں© © ©ں يں©§ کëی§");
    if (this.txtuserName.Text != "")
    this.sqlcom.Parameters[3].Value = this.txtuserName.Text;
    else
    MessageBox.Show("ëںê کں© ©ی ©ں يں©§ کëی§");
    if (this.txtpassword.Text != "")
    this.sqlcom.Parameters[4].Value = Md5.GetHash(txtpassword.Text);
    else
    MessageBox.Show("©êھ م ي© ©ں يں©§ کëی§");
    if (this.txtretry.Text == "")
    MessageBox.Show("¢ک©ں© ©êھ م ي© ©ں يں©§ کëی§");

    if (this.chken_rec.Checked)
    this.sqlcom.Parameters[5].Value = this.chken_rec.Checked;
    else
    this.sqlcom.Parameters[5].Value = dbnull;
    if (this.chkvehicel.Checked)
    this.sqlcom.Parameters[6].Value = this.chkvehicel.Checked;
    else
    this.sqlcom.Parameters[6].Value = dbnull;
    if (this.chkcargo.Checked)
    this.sqlcom.Parameters[7].Value = this.chkcargo.Checked;
    else
    this.sqlcom.Parameters[7].Value = dbnull;
    if (this.chkdriver.Checked)
    this.sqlcom.Parameters[8].Value = this.chkdriver.Checked;
    else
    this.sqlcom.Parameters[8].Value = dbnull;
    if (this.chkexp_bill.Checked)
    this.sqlcom.Parameters[9].Value = this.chkexp_bill.Checked;
    else
    this.sqlcom.Parameters[9].Value = dbnull;
    if (this.chkcity.Checked)
    this.sqlcom.Parameters[10].Value = this.chkcity.Checked;
    else
    this.sqlcom.Parameters[10].Value = dbnull;
    if (this.chk.Checked)
    this.sqlcom.Parameters[11].Value = this.chk.Checked;
    else
    this.sqlcom.Parameters[11].Value = dbnull;
    if (this.chkbill.Checked)
    this.sqlcom.Parameters[12].Value = this.chkbill.Checked;
    else
    this.sqlcom.Parameters[12].Value = dbnull;
    if (this.chkexp_road_bill.Checked)
    this.sqlcom.Parameters[13].Value = this.chkexp_road_bill.Checked;
    else
    this.sqlcom.Parameters[13].Value = dbnull;
    if (this.chkuser.Checked)
    this.sqlcom.Parameters[14].Value = this.chkuser.Checked;
    else
    this.sqlcom.Parameters[14].Value = dbnull;
    if (this.chkchangepass.Checked)
    this.sqlcom.Parameters[15].Value = this.chkchangepass.Checked;
    else
    this.sqlcom.Parameters[15].Value = dbnull;
    if (this.chksearch_sen_rec.Checked)
    this.sqlcom.Parameters[16].Value = this.chksearch_sen_rec.Checked;
    else
    this.sqlcom.Parameters[16].Value = dbnull;
    if (this.chksearch_cargo.Checked)
    this.sqlcom.Parameters[17].Value = this.chksearch_cargo.Checked;
    else
    this.sqlcom.Parameters[17].Value = dbnull;
    if (this.chksearch_driver.Checked)
    this.sqlcom.Parameters[18].Value = this.chksearch_driver.Checked;
    else
    this.sqlcom.Parameters[18].Value = dbnull;
    if (this.chksearchvehicel.Checked)
    this.sqlcom.Parameters[19].Value = this.chksearchvehicel.Checked;
    else
    this.sqlcom.Parameters[19].Value = dbnull;
    if (this.chksearch_bill.Checked)
    this.sqlcom.Parameters[20].Value = this.chksearch_bill.Checked;
    else
    this.sqlcom.Parameters[20].Value = dbnull;
    if (this.chksearch_order.Checked)
    this.sqlcom.Parameters[21].Value = this.chksearch_order.Checked;
    else
    this.sqlcom.Parameters[21].Value = dbnull;
    if (this.chkedit.Checked)
    this.sqlcom.Parameters[22].Value = this.chkedit.Checked;
    else
    this.sqlcom.Parameters[22].Value = dbnull;
    if (this.chkdel.Checked)
    this.sqlcom.Parameters[23].Value = this.chkdel.Checked;
    else
    this.sqlcom.Parameters[23].Value = dbnull;
    if (this.chkinsert.Checked)
    this.sqlcom.Parameters[24].Value = this.chkinsert.Checked;
    else
    this.sqlcom.Parameters[24].Value = dbnull;

    if (txtpassword.Text != txtretry.Text)
    {
    MessageBox.Show("©êھ م ي© ي¢ک©ں© ©êھ م ي© ©ں ­¥ی¥ يں©§ کëی§", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
    txtpassword.Text = "";
    txtretry.Text = "";
    }
    else
    {
    sqlcom.CommandText = "insert into login( idUser,name,lName,userName,password,sen_rec,vehice l,cargo,driver,exp_bill,city,order1,bill,exproad_b ill,defineuser,changepass,searchsen_rec,search_car go,search_driver,search_vehivel,search_bill,search _order,edit,del,register)values(@iu,@n,@l,@un,@p,@ xx,@v,@c,@d,@eb,@city,@o,@bill,@expb,@du,@cp,@sbr, @sc,@sd,@sv,@sb,@so,@edit,@del,@insert)";
    sqlcon.Open();
    sqlcom.ExecuteNonQuery();
    sqlcon.Close();

    }
    }
    catch (Exception ex)
    {
    sqlcon.Close();
    MessageBox.Show(ex.ToString());
    }

  6. #6
    کاربر دائمی آواتار bachebahal_1363
    تاریخ عضویت
    اسفند 1384
    محل زندگی
    اینترنت
    پست
    336

    نقل قول: خطا در درج

    اول چک کن ببین اگر فیلدی داری که Identity هست مقدار بهش ندی شاید اشکال از این باشه .

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •