0
「SQLConn()。Open()」正在標記錯誤「Class'System.Data.SqlClient.SqlConnection'無法被索引,因爲它沒有默認屬性。」我很困惑,因爲我在其他(工作)文件中使用完全相同的語法。建議感激。謝謝SQLConn類錯誤
Using SQLConn = New SqlConnection(ConfigurationManager.ConnectionStrings("DataConnectionRemoteSQL").ConnectionString)
Try
SQLConn().Open()
Using cmd = New SqlCommand()
cmd.Connection = SQLConn
cmd.CommandText = "Select_UserLoginData"
cmd.CommandType = CommandType.StoredProcedure
param1 = cmd.Parameters.AddWithValue("@usern", username_s)
param1.Direction = ParameterDirection.Input
param1.DbType = DbType.String
Using user_rs = cmd.ExecuteReader()
If user_rs.Read() Then
'Create hash of plain text password entered
hashedpassword_s = s_CreateHash(password_s, user_rs("Salt"))
'If this password doesn't match what's stored in the database
If Not hashedpassword_s = user_rs("Hashed") Then
lbl_ErrorPanelText.Text = "Incorrect login credentials!"
pn_ErrorPanel.Visible = True
Else
Session("check") = 1
user_rs.Close()
Response.Redirect("menu.aspx", False)
End If
Else
lbl_ErrorPanelText.Text = "Incorrect login credentials!"
pn_ErrorPanel.Visible = True
End If
End Using
End Using
Catch ex As Exception
lbl_ErrorPanelText.Text = "Error establishing a database connection!"
pn_ErrorPanel.Visible = True
End Try
End Using