Results 1 to 8 of 8

Thread: [RESOLVED] [2005] display info on textbox, urgent, pls help if possible

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    28

    Resolved [RESOLVED] [2005] display info on textbox, urgent, pls help if possible

    after i set a button to validate the id and password, i wana show the particualrs of that person in repective textboxes
    like, name: name of the person

    i use tis to do the validation
    but i do not noe how to validate 2 fields, id n pw the same time
    so after validating, how to do for showing the fields in the textboxes?
    ----------

    Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\project\db1.mdb"
    Dim con As OleDb.OleDbConnection
    Dim dr As OleDb.OleDbDataReader
    Dim cmd As New OleDb.OleDbCommand

    Try

    Dim strselect As String = "Select Id from member where BId = '" & IdTB.Text & "' and pw='" & pwTB.Text & "'"

    'create a new connection
    con = New OleDb.OleDbConnection(strcon)
    con.Open()
    cmd.Connection = con
    cmd.CommandText = strselect
    dr = cmd.ExecuteReader

    Catch eException As Exception
    MessageBox.Show(eException.Message)
    End Try
    ------------------------

    pls help, i need to submit tis project b4 9am tml >.<
    my 1st project on vb so errr..... nothing too complicated pls >.<

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] display info on textbox, urgent, pls help if possible

    Quote Originally Posted by kyosugi
    after i set a button to validate the id and password, i wana show the particualrs of that person in repective textboxes
    like, name: name of the person

    i use tis to do the validation
    but i do not noe how to validate 2 fields, id n pw the same time
    so after validating, how to do for showing the fields in the textboxes?
    ----------

    Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\project\db1.mdb"
    Dim con As OleDb.OleDbConnection
    Dim dr As OleDb.OleDbDataReader
    Dim cmd As New OleDb.OleDbCommand

    Try

    Dim strselect As String = "Select Id from member where BId = '" & IdTB.Text & "' and pw='" & pwTB.Text & "'"

    'create a new connection
    con = New OleDb.OleDbConnection(strcon)
    con.Open()
    cmd.Connection = con
    cmd.CommandText = strselect
    dr = cmd.ExecuteReader

    Catch eException As Exception
    MessageBox.Show(eException.Message)
    End Try
    ------------------------

    pls help, i need to submit tis project b4 9am tml >.<
    my 1st project on vb so errr..... nothing too complicated pls >.<
    Hi,

    You could try something like:

    TextBox1.Text = idTB.Text & pwTB.Text

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] display info on textbox, urgent, pls help if possible

    Once you've created the DataReader you need to read the data from it. You read a row of data and you can then assing the values from the fields of that row to wherever you want, e.g.
    VB Code:
    1. 'Optimise the command.
    2. dr = cmd.ExecuteReader(CommandBehavior.SingleRow Or CommandBehavior.CloseConnection)
    3.  
    4. If dr.Read() Then
    5.     'The reader contains data.
    6.     Me.nameText.Text = dr("Name")
    7.     'etc.
    8. End If
    9.  
    10. dr.Close()
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    28

    Re: [2005] display info on textbox, urgent, pls help if possible

    i tried but nothing were displayed out
    --------
    Private Sub EditMember_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =C:\Documents and Settings\Jasmine\My Documents\project\db1.mdb"
    Dim con As OleDb.OleDbConnection
    Dim dr As OleDb.OleDbDataReader
    Dim cmd As New OleDb.OleDbCommand
    Try
    Dim strselect As String = "Select Fname, Lname, Address1, Address2, Address3, ContactNo, HandPhNo, Email, CourseOfStudy from member where BorrowerId = '" & EditMemberLog.idTB.Text & "'"

    'create a new connection
    con = New OleDb.OleDbConnection(strcon)
    con.Open()
    cmd.Connection = con
    cmd.CommandText = strselect
    dr = cmd.ExecuteReader(CommandBehavior.SingleRow Or CommandBehavior.CloseConnection)

    If dr.Read Then
    Me.fNameTB.Text = dr("Fname")
    Me.lNameTB.Text = dr("Lname")
    Me.add1TB.Text = dr("Address1")
    Me.add2TB.Text = dr("Address2")
    Me.add3TB.Text = dr("Address3")
    Me.hmTB.Text = dr("ContactNo")
    Me.hpTB.Text = dr("HandPhNo")
    Me.emailTB.Text = dr("Email")
    Me.cosCB.Text = dr("CourseOfStudy")

    End If
    dr.Close()


    Catch eException As Exception
    MessageBox.Show(eException.Message)
    End Try

    End Sub
    ---------------------
    did i miss out something?
    Last edited by kyosugi; Aug 6th, 2006 at 08:52 AM.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] display info on textbox, urgent, pls help if possible

    Then chances are that no records were returned. This is where you have to debug. Put a breakpoint on the first line and step through the code line by line. You can then check whether Read returns True and, if so, what each field contains. If a car is not running properly you start it up and look under the hood. Software is the same.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    28

    Re: [2005] display info on textbox, urgent, pls help if possible

    errr......i did not learn how to debug... do noe bout the buttons for step into, out n over, but not sure on how to use them, how do i noe if Read returns True?

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] display info on textbox, urgent, pls help if possible

    In the code window, click the first line of that code and press F9. This will place a break point on that line. Now, when you run your project it will stop at that line. You can then press the F10 key to step through the code line by line. If you do that you will be able to see whether the code enters the If block or not. If it doesn't then that's a pretty obvious indication of why your TextBoxes are not populated. While execution is stopped you can mouse over variables and properties to see what they contain, plus you can use the Locals and Watch windows to evaluate various expressions. The Locals window displays specific references that are valid in the current context. The Watch window allows you to enter and variable or property name or expression and have it evaluated at the current moment. As you step through the code and values change they are reflected in the Locals and Watch windows. The IDE contains many oter debugging tools too.

    Like I said, you can't just look at something and see why it doesn't work in any but the simplest cases. You have to see something in action to diagnose most issues.

    If the code doesn't enter the If block then that means that there's an issue with your query because it is not matching any records. What type is the BorrowerId column? Is it text or a number?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    28

    Re: [2005] display info on textbox, urgent, pls help if possible

    its a text column

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