CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2006
    Posts
    449

    Using ASPNetDB.mdb

    Hi all,

    I work in Visual Studio 2005 with Access as my database. Am using the in-built membership management (ASPNetDB.mdb). I need to display the complete data from the table 'aspnet_Users' based on the login, Hope am clear... Please check the below select statement... I know am wrong... so please correct me...!

    "SELECT ApplicationId, UserId, UserName, MobileNumber, MobileAlias, IsAnonymous, LastActivityDate FROM aspnet_Users WHERE (UserName = Login1.LayoutTemplate.UserName.ID)"

    I think am not clear... see if this helps you...

    I am trying to retrieve the username. After a user logs in, on the next page i have a gridview to diplay that user's info. I want to use that control in the SQL to bring back the data. Something like SELECT username, email from ASPNER_Users WHERE username = loginname.

    Then I tried with this following select statement... there were no errors but it says 'There are no matching records' but the records are there for the loggedin user...!

    SELECT * FROM aspnet_Users WHERE (UserName = '" + Membership.GetUser().UserName + "')

    Any help would be appreciated!
    Last edited by laxatcg1; December 9th, 2009 at 09:42 AM. Reason: More information
    Thank you for your support.

    Best regards,
    Lax

  2. #2
    Join Date
    Oct 2006
    Posts
    449

    Re: Using ASPNetDB.mdb

    Hi all,

    Hope my query is clear in my earlier post... I kindly request you to guide me to proceed from there... as I got stuck... am also trying my best and I do edit my earlier post as and when I update my work.

    Please help me...!
    Thank you for your support.

    Best regards,
    Lax

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Using ASPNetDB.mdb

    Take a look at this link:
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Oct 2006
    Posts
    449

    Re: Using ASPNetDB.mdb

    Thank you for your reply post. But these samples are from VS 2008 and I work in VS 2005 and I couldn;'t convert the same. Please help me out with some other alternate option. Thank you.
    Thank you for your support.

    Best regards,
    Lax

  5. #5
    Join Date
    Oct 2006
    Posts
    449

    Re: Using ASPNetDB.mdb

    I have changed my select statement to the following:

    SelectCommand="SELECT * FROM aspnet_Users WHERE (UserName = '" + Membership.GetUser(this.User.Identify.Name) + "')"

    This time there's no data getting displayed and there's no error too...!

    Please help me on this...!
    Thank you for your support.

    Best regards,
    Lax

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Using ASPNetDB.mdb

    That's your problem, if you have the exact thing that you posted.

    '" + Membership.GetUser(this.User.Identify.Name) + "')

    Here's some VB6 code. Around dates, there's #. Around strings, there's a '
    Around numbers (unformatted) there is NO character. Its the same for all SQL

    Code:
    Private Function GetRecordset(ByVal pdteSearchDate As Date) As ADODB.Recordset
    Dim strSQL      As String
    Dim adoRec      As ADODB.Recordset
        strSQL = "SELECT * "
        strSQL = strSQL & "FROM AS_Createsched "
        strSQL = strSQL & "WHERE AS_Createsched.CSIN_dates = #" & Format$(pdteSearchDate, "d mmm yyyy") & "# "
        strSQL = strSQL & "AND HOUR(AS_Createsched.CSIN_times) = " & Format$(pdteSearchDate, "hh") & " "
        strSQL = strSQL & "AND MINUTE(AS_Createsched.CSIN_times) = " & Format$(pdteSearchDate, "nn") & " "
        Set adoRec = New ADODB.Recordset
        adoRec.Open strSQL, GetConnString, adOpenForwardOnly, adLockReadOnly
        Set GetRecordset = adoRec
        Set adoRec = Nothing
    End Function
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Oct 2006
    Posts
    449

    Re: Using ASPNetDB.mdb

    Thank you for your reply post....But I still couldn't get it...! I know am still wrong with my select statement.... could you please correct my Select statement ?
    Thank you for your support.

    Best regards,
    Lax

  8. #8
    Join Date
    Oct 2006
    Posts
    449

    Re: Using ASPNetDB.mdb

    I tried using this select statement:

    Select * FROM aspnet_Users WHERE (UserName = '<%=Membership.GetUser(this.User.Identify.Name).ToString;%>')"

    But this doesn't return any data and it was just blank...!
    Thank you for your support.

    Best regards,
    Lax

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Using ASPNetDB.mdb

    Break it downl. Save it as a string, and then use that string in your SQL statement.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured