您好,我怎麼能在我的系統編寫代碼後訪問頁面,那就是用戶被授權登錄
1)用戶1:添加,刪除,更新,查看 2)用戶2:更新只 3 )用戶3:僅查看
我使用vb.net和訪問數據庫。有一些我的代碼
Dim strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\user\Documents\MIS\LabSystem\LabTestSystem\LabSystemDB.mdb"
Dim conn As New OleDbConnection(strConnectionString)
conn.Open()
'Enter default login details username and password
cmd = New OleDbCommand("select * from Login where username='" & TextBox1.Text & "' and password='" & TextBox2.Text & "'", conn)
dt.Clear()
da = New OleDbDataAdapter(cmd)
da.Fill(dt)
If dt.Rows.Count > 0 Then
Session("username") = TextBox1.Text
Response.Redirect("Main.aspx")
Else
TextBox1.Text = ""
TextBox2.Text = ""
Label1.Text = "Incorrect value: Invalid login or password."
Label1.ForeColor = System.Drawing.Color.Red
End If
除非這是一個非常小的私人網站,MS訪問不是數據庫的好選擇。無論何種類型的網站,當您不清理輸入內容時,創建用戶角色都毫無意義。 MS Access比其他數據庫更容易受到SQL注入的影響,但它不是免疫的。我建議你在整個事情變得笨拙之前立即切換到參數。 – Fionnuala