10-01-25, 03:15 AM
الرجاء تعديل كود حذف البيانات بحيث إذا كان الجدول فارغ تظهر رسالة بأنه لا توجد بيانات في الجدول
وهذا كود الحذف
وهذا كود الحذف
كود :
Dim Position As Integer = DataGridView1.CurrentRow.Index
Dim ID_Position As Integer = DataGridView1.Rows(Position).Cells("BID").Value
Dim CmdDelete As New SqlCommand
With CmdDelete
.Connection = Conn
.CommandType = CommandType.Text
.CommandText = "Delete From Tab_Books Where BID = @BID"
.Parameters.Clear()
.Parameters.AddWithValue("@BID", SqlDbType.Int).Value = ID_Position
End With
Try
If Conn.State = 1 Then Conn.Close()
Conn.Open()
CmdDelete.ExecuteNonQuery()
Conn.Close()
MsgBox("تم حذف اســم الكتـاب المحـدد.", MsgBoxStyle.Information, "إجـراء الحـذف")
CmdDelete = Nothing
Catch ex As Exception
Conn.Close()
MsgBox(Err.Description, MsgBoxStyle.Information)
Finally
If Conn.State = ConnectionState.Open Then Conn.Close()
End Try
إذا طُعِنتَ من الخلفِ فاعلمْ أنك في المقدمةِ


