0
嗨我完全失去了這段代碼(也非常新)我試圖在else語句後創建一個會話。你如何創建一個會話,並讓它被另一個文件讀取?vb登錄會話
Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost;Port=3306; user id=****; password=****; database=testtable"
'see if connection failed.
Try
conn.Open()
Catch myerror As MySqlException
MessageBox.Show("Error Connection to Database: " & myerror.Message)
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM members Where login='" & UsernameTextBox.Text & "' and passwd='" & PasswordTextBox.Text & "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
'see if user exits.
If myData.HasRows = 0 Then
MessageBox.Show("Invalid Username/Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Dim login As String = System.Web.HttpContext.Current.Session("login")
System.Web.HttpContext.Current.Session("login") = UsernameTextBox.Text
Dim Form1 = New Form1
Form1.Show()
Me.Visible = False
End If
感謝所有幫助
您有一個SQL注入漏洞。 – SLaks 2012-04-25 12:54:46
Metro?的WinForms? WPF? Silverlight的? ASP.Net? MonoTouch的? – SLaks 2012-04-25 12:55:10
我知道我有漏洞,但這僅僅是爲了我學習 – user1356182 2012-04-25 13:04:39