我想弄清楚在哪里添加我的Response.Redirect(“userAdmin.aspx)到我的代码。我已经尝试了很多不同的变体,但提交按钮什么都不做。谁能帮助?我将不胜感激!在哪里可以添加Respons.Redirect?
这里是我的代码
Protected Sub butSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butSubmit.Click
Dim myReader As Data.SqlClient.SqlDataReader
Dim mySqlConnection As Data.SqlClient.SqlConnection
Dim mySqlCommand As Data.SqlClient.SqlCommand
'Establish the SqlConnection by using the configuration manager to get the connection string in our web.config file.
mySqlConnection = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings ("ConnectionString").ToString())
Dim sql As String = "SELECT password FROM MyUsers WHERE username = '" & Me.TextBox1.Text & "'"
mySqlCommand = New Data.SqlClient.SqlCommand(sql, mySqlConnection)
Try
mySqlConnection.Open()
myReader = mySqlCommand.ExecuteReader()
If (myReader.HasRows) Then
myReader.Read()
Dim password As String = myReader("password")
If (password = Me.TextBox2.Text) Then
'Open page with users and roles
Dim message As String = "Correct password"
Dim style As MsgBoxStyle = MsgBoxStyle.OkOnly
Dim title As String = "Authenticated"
MsgBox(message, style, title)
End If
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
Finally
If Not (myReader Is Nothing) Then
myReader.Close()
End If
If (mySqlConnection.State = Data.ConnectionState.Open) Then
mySqlConnection.Close()
End If
End Try
End Sub
asp.net应用程序中的MsgBox和控制台? – Aristos 2013-03-01 08:12:38