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

    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:
        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
                    lblMsg.Visible = True
                    lblMsg.Text = "Invalid Logon Information"
                End If
            End If
        End Sub

  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Welcome to DevX

    Try something like
    sql = "select [ number], usrdet.nameFst
     sql = sql & "inner join userdet on [ number] = [ number]
     sql = sql & "from log logtbl "
     sql = sql & "where uname = '" &  txtUsrName.Text & "' " 
     sql = sql & "and pass = '" & txtPwd.Text & "' "

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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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