0
我正在嘗試使用此代碼來驗證刪除操作。它只能在輸入框中輸入的代碼用於超級管理員時才執行,但它會返回一個錯誤「位置1沒有行」。任何人都可以提供更好的代碼結構將不勝感激。根據用戶級別驗證命令
Private Sub btnD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnD.Click
dbProvider = "Provider=Microsoft.Ace.OLEDB.12.0;"
dbSource = "Data Source = C:\Users\Blessing\Documents\IBCARIP.accdb;Persist Security Info=False"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "select UserID from Users where UserID = 'dlass8504'"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds2, "IBCARIP")
con.Close()
If InputBox("Please input your UserID to complete operation").ToString <> ds2.Tables("IBCARIP").Rows(inc).Item("UserID").ToString Then
MsgBox("You do not posess sufficient previlegies to perfom this operation..!", MsgBoxStyle.Critical)
ElseIf MsgBox("Do you really want to Delete this Record?", MsgBoxStyle.YesNo) = MsgBoxResult.Ok Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("IBCARIP").Rows(inc).Delete()
MaxRows = MaxRows - 1
inc = 0
da.Update(ds, "IBCARIP")
navigaterecords()
End If
End Sub
如何,如果你禁用刪除按鈕年初的時候,你發現用戶是沒有privilage? – matzone
你可以幫助一個代碼片段爲 –