Results 1 to 4 of 4

Thread: SQL Querie

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    159

    SQL Querie

    Hay all

    i want to query some data from a database, but not sure how to do it.

    i have a Form with data bound to textBoxes. To do this i Configured a oleDbDataAdapter with the following SQL statement:

    SELECT Address, DateOfBirth, DateOfEmployment, EmployeesID, FirstName, LastName, Notes, PhoneNumber, PostCode, Title
    FROM Employees

    all the above does is select and display all the fields from the employee Database

    After configuring the oleDbDataAdapter i then generated a DataSet called objdsEmployee

    The textboxes are bount to fields in the database:

    Employee Database fields:

    • EmployeesID
      FirstName
      LastName
      Title
      DateOfBirth
      Address
      PostCode
      PhoneNumber
      DateOfEmployment
      Notes


    All the above works fine but... i want to SELECT data WHERE the membersID is equla to TextBox1

    im not sure how to do this could any 1 help?

    thanks

  2. #2
    Lively Member nokia8210's Avatar
    Join Date
    Dec 2002
    Location
    Coventry
    Posts
    92
    why dont you use a SqlDataAdapter instead?

    you would put it in the textbox1 lost focus or on a button click event to fill the dataset based on the text in the box.


    i would do it like this



    sqlEmployees.parameters("@ID").value=textbox1.text
    sqlEmployees.fill(Dataset)


    textbox2.text=dataset.tables(0).Rows(0).item("ColumnName")

    just add the same row as above for each textbox changing the box no and the ColumnName.


    if you need anymore help just ask

  3. #3
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353


    “SELECT Address, DateOfBirth, DateOfEmployment, EmployeesID, FirstName, LastName, Notes, PhoneNumber, PostCode, Title
    FROM Employees where EmployeesID = ‘“ & TextBox1.text & “’ “

    Here a string sql statement!
    Last edited by mudfish; Mar 2nd, 2004 at 07:22 PM.
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    159
    i would use a sqlAdapter but i aint got an sql server to store my database. i got SQL Server 2002 Developers edition but i cant get it to work dunno why!

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