[問題] ASP.NET 登入問題

看板Web_Design作者 (夜月)時間16年前 (2009/12/02 02:31), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
我是自己做login 好像一直都連不到資料庫 不知是哪裡出了問題 請幫忙解答~謝謝 這是他顯示的錯誤指示 使用者 'SAMPLE1\ASPNET' 的登入失敗。 描述: 在執行目前 Web 要求的過程中發生未處理的例外情形。請檢閱堆疊追蹤以取得錯 誤的詳細資訊,以及在程式碼中產生的位置。 例外詳細資訊: System.Data.SqlClient.SqlException: 使用者 'SAMPLE1\ASPNET' 的登 入失敗。 我寫的程式 Imports System.Data.SqlClient Imports System.Web.Configuration Partial Class Login Inherits System.Web.UI.Page Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click Dim connString As String = WebConfigurationManager.ConnectionStrings("memberlogin").ConnectionString Dim conn As New SqlConnection(connString) conn.Open() <==他指這邊錯 Dim SqlStr As String = "select UserId from member where UserId=" SqlStr += Server.HtmlEncode(CType(sender, System.Web.UI.WebControls.Login).UserName) SqlStr += "'and Password='" & Server.HtmlEncode(CType(sender, System.Web.UI.WebControls.Login).Password) & "'" Dim cmd As New SqlCommand(SqlStr, conn) Dim txtID As String = CType(cmd.ExecuteScalar(), String) cmd.Dispose() conn.Close() conn.Dispose() If (Not String.IsNullOrEmpty(txtID)) Then FormsAuthentication.RedirectToLoginPage() Else FormsAuthentication.RedirectToLoginPage() End If End Sub End Class -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.217.31.215 ※ 編輯: night1021 來自: 61.217.31.215 (12/02 02:33)

12/02 07:49, , 1F
檢查一下 ConnectionString 連 DB 帳、密是否有問題
12/02 07:49, 1F

12/09 11:25, , 2F
恩~謝謝
12/09 11:25, 2F
文章代碼(AID): #1B5M4Ndx (Web_Design)