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)
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)
'fstName = dtset.Tables("USRDET")
lblMsg.Visible = True
lblMsg.Text = usrID
lblMsg.Visible = True
lblMsg.Text = "Invalid Logon Information"
Welcome to DevX
Try something like
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
By max caber in forum .NET
Last Post: 07-03-2007, 02:06 PM
By madhulatha_b in forum VB Classic
Last Post: 12-07-2006, 10:33 AM
By BernS in forum VB Classic
Last Post: 06-20-2002, 10:27 AM
By John in forum VB Classic
Last Post: 10-12-2001, 06:09 PM
By Michael Shutt in forum XML
Last Post: 06-26-2001, 12:51 PM
Tags for this Thread
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center