Data Retrieval Problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Data Retrieval Problem

  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Data Retrieval Problem

    I have two Tables as following:
    1. LOG having fields( id number,usrname text, pass text)
    2. UsrDet having fields( id number, nameFst text, NameLst text,Email text)
    I want when user enters his Username & Password, My code should return ID of that user from LOG table and on behalf of that ID I wanted to welcome that user by fetching his Fisrt Name from USRDET table on next page. To test the Code I still wanted to show the retrieved value in LABEL… The Code I m using is as Following but I m not able to fetch UserID..PLS help me by altering this code:
    Code:
        Dim con As OleDbConnection
        Dim comm As OleDbDataAdapter
        Dim dtset As New DataSet
        Dim sql As String
        Dim NewSQL As String
    
    Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
    
            If txtUsrName.Text <> "" And txtPwd.Text <> "" Then
                sql = "select id from log where uname=" & "'" & txtUsrName.Text & "'" & " and pass=" & "'" & txtPwd.Text & "'"
                con = New OleDbConnection("provider=microsoft.jet.oledb.4.0;datasource=c:\comp.mdb")
                comm = New OleDbDataAdapter(sql, con)
                comm.Fill(dtset, "log")
                If dtset.Tables("log").Rows.Count > 0 Then
                    Dim usrID As Integer
                    NewSQL = "select NameFst from usrdet where id=" & usrID
                    comm = New OleDbDataAdapter(NewSQL, con)
                    comm.Fill(dtset, "usrdet")
                    'fstName = dtset.Tables("USRDET")
                    lblMsg.Visible = True
                    lblMsg.Text = usrID
                Else
                    lblMsg.Visible = True
                    lblMsg.Text = "Invalid Logon Information"
                End If
            End If
        End Sub

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Welcome to DevX

    Try something like
    Code:
    sql = "select [logtbl.id number], usrdet.nameFst
     sql = sql & "inner join userdet on [logtbl.id number] = [usrdet.id number]
     sql = sql & "from log logtbl "
     sql = sql & "where uname = '" &  txtUsrName.Text & "' " 
     sql = sql & "and pass = '" & txtPwd.Text & "' "
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Problem with Data Adapter Update
    By max caber in forum .NET
    Replies: 4
    Last Post: 07-03-2007, 01:06 PM
  2. Problem with fetching data
    By madhulatha_b in forum VB Classic
    Replies: 0
    Last Post: 12-07-2006, 09:33 AM
  3. Data Environment - Cache Results problem
    By BernS in forum VB Classic
    Replies: 0
    Last Post: 06-20-2002, 09:27 AM
  4. Data List Control Problem
    By John in forum VB Classic
    Replies: 0
    Last Post: 10-12-2001, 05:09 PM
  5. problem with data islands and images
    By Michael Shutt in forum XML
    Replies: 0
    Last Post: 06-26-2001, 11:51 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center