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

نام تاپیک: تشخیص تکراری بودن یک ردیف در بانک

Threaded View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #13

    نقل قول: تشخیص تکراری بودن یک ردیف در بانک

    من کد برنامم رو به جای اینکه insert کنم و delete کنم به این صورت نوشتم و بهش گفتم که اگر همچین ردیفی وجود داره عمل insert رو انجام بده ولی نمی دونم چرا خطای زیر رو داد

    If DataGridView1.CurrentRow.Cells(0).Value Then
    For j AsInteger = 0 To DataGridView2.RowCount - 1
    If DataGridView2.Rows(j).Cells(0).Value Then
    If DataGridView2.Rows(j).Cells(4).Value <> 0 Then
    a = DataGridView1.CurrentRow.Cells(4).Value / DataGridView2.Rows(j).Cells(4).Value
    m = (DataGridView1.CurrentRow.Cells(1).Value * 100) + DataGridView2.Rows(j).Cells(1).Value
    cmd.CommandText =
    " select * from shakhes2 where idshakhes='" & m & "' and sal81 = '" & a & "'"
    dr = cmd.ExecuteReader()
    If dr.hasrows = TrueThen
    dr.read()
    cmd.CommandText =
    " UPDATE shakhes2 SET idshakhes,sal81 =" & m & "," & a & " WHERE idshakhes = " & m
    cmd.ExecuteNonQuery()
    Else
    cmd.CommandText = " INSERT INTO shakhes2(idshakhes,sal81) VALUES(@m,@a)"
    cmd.Parameters.Add("@idshakhes", SqlDbType.Int)
    cmd.Parameters.Add(
    "@sal81", SqlDbType.Int)
    cmd.Parameters(
    "@idshakhes").Value = m
    cmd.Parameters(
    "@sal81").Value = a
    cmd.ExecuteNonQuery()
    EndIf
    Else : a = 0
    EndIf
    EndIf
    Next

    پیغام خطایی که صادر می کنه
    آخرین ویرایش به وسیله bahar2008 : جمعه 07 تیر 1387 در 14:11 عصر

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

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