Results 1 to 2 of 2

Thread: finding a record in a table

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    finding a record in a table

    Hello

    I want to be able to get one record from the teacher's table and still the record in the Database. The user will enter the ID number and then press a find button. The contents of this record can be
    displayed in some text boxes.

    Code:
    cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False";
    				OleDbDataAdapter daTeacher = new OleDbDataAdapter("SELECT * FROM Teacher WHERE teacherID = '" + txtIDNumber.Text + "' ",cnnTeacher);
    				OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher);
    				
    				daTeacher.Fill(dtTeacher);
    				
    				txtName.text = //code to go here for display the name of the teacher from finding ID number
    Many thanks in advance
    steve

  2. #2
    Hyperactive Member fret's Avatar
    Join Date
    Sep 2004
    Posts
    472
    try...just try:
    VB Code:
    1. daTeacher.Fill(dtTeacher);
    2. txtName.Text=dtTeacher.Rows[0][1].ToString();
    hope it helps.

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