none
無法使用MsgBox來debug...QQ RRS feed

  • 問題

  • Dear All
    程式碼如下
    Namespace SIMS
        Public Class MEMBERSHIP
            Private Shared db As New SIMS.SimsDB
    Public Shared Function validateUser(ByVal login As String, ByVal password As String) As Boolean
                Dim strSQL As String
                Dim dr As System.Data.SqlClient.SqlDataReader
                strSQL = "select * from MEMBERS where LOGIN = '" & login & "' and PASSWORD = '" & password & "'"
                dr = db.Read(strSQL)
                MsgBox(strSQL) '==>就是這一行
                If dr.HasRows Then
                    Return True
                Else
                    Return False
                End If
            End Function
    End Class
    End Namespace

    在上面程式碼當中...此支程式我是寫在membership.vb裡面,
    我的msgBox都沒有作用ㄋㄟ....奇怪....
    各位大大幫我看看吧..^^ 感恩

    ps:我是在網頁中使用此物件.........網頁如下....(login.aspx,我的vb碼是與網頁碼分開)
    ================================================
    login.aspx:
    =========
    <%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/MasterPage.master" CodeFile="Login.aspx.vb" Inherits="_Login" %>

    <asp:Content ID="Content1" runat="server" ContentPlaceHolderID="maincontent">   

        <div id="adminedit" style="height: 410px" >
                           
            <div style="text-align: center">
                <table style="width: 100%">
                    <tr>
                        <td style="width: auto" rowspan="2">
                        </td>
                        <td style="width: 300px">
                            <fieldset style="height: 166px;width:300px">                          
                                <legend>User Login</legend>
                                <asp:Login ID="Login1" runat="server">
                                    <LoginButtonStyle CssClass="submit" />
                                </asp:Login>
                            </fieldset>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 300px">
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </asp:Content>
    ==========================================================

    login.aspx.vb
    =========================
    Partial Class _Login
        Inherits System.Web.UI.Page

        Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate

            If Membership.ValidateUser(Login1.UserName, Login1.Password) Then
                e.Authenticated = True
            End If
        End Sub

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        End Sub
    End Class
    =========================================================


    2006年6月18日 上午 09:31

解答

  • 這個還是請您先作Code Trace的動作,單從程式碼來看,應該是先發生Error,然後沒有Run到MsgBox那段‧
    2006年6月18日 下午 12:30
    版主