Results 1 to 3 of 3

Thread: [RESOLVED] Displaying data from database using what i entered into a textbox, help please

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2014
    Posts
    8

    Resolved [RESOLVED] Displaying data from database using what i entered into a textbox, help please

    hello there, i trying to display certain data from a database i have using a value i entered in a textbox
    here is the code i have so far
    txtDate.Text = frmViewBookings.txtDate.Text

    dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
    dbSource = "Data Source = C:\TheGarageDatabase.mdb"

    con.ConnectionString = dbProvider & dbSource

    con.Open()


    sql = "SELECT * FROM Bookings WHERE Date = '" & txtDate.Text & "'"

    da = New OleDb.OleDbDataAdapter(sql, con)
    da.Fill(ds, "TheGarageDatabase")
    dgvBookingSearch.DataSource = ds.Tables("TheGarageDatabase")
    con.Close()

    maxRows = ds.Tables("TheGarageDatabase").Rows.Count
    MsgBox(maxRows)
    inc = 0

    the line of code causing the issue is this;
    sql = "SELECT * FROM Bookings WHERE Date = '" & txtDate.Text & "'"
    any help please

  2. #2
    Addicted Member thetimmer's Avatar
    Join Date
    Jan 2014
    Location
    Plano, Texas
    Posts
    243

    Re: Displaying data from database using what i entered into a textbox, help please

    What's the error you're getting ?

    Also, please remember wrap your code in [C0DE] [/C0DE] tags so it is easier to read.

    Code:
    txtDate.Text = frmViewBookings.txtDate.Text
    
    dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
    dbSource = "Data Source = C:\TheGarageDatabase.mdb"
    
    con.ConnectionString = dbProvider & dbSource
    
    con.Open()
    
    
    sql = "SELECT * FROM Bookings WHERE Date = '" & txtDate.Text & "'"
    
    da = New OleDb.OleDbDataAdapter(sql, con)
    da.Fill(ds, "TheGarageDatabase")
    dgvBookingSearch.DataSource = ds.Tables("TheGarageDatabase")
    con.Close()
    
    maxRows = ds.Tables("TheGarageDatabase").Rows.Count
    MsgBox(maxRows)
    inc = 0
    Last edited by thetimmer; Apr 17th, 2014 at 08:35 AM.
    _____________
    Tim

    If anyone's answer has helped you, please show your appreciation by rating that answer.
    When you get a solution to your issue remember to mark the thread Resolved.


    reference links

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2014
    Posts
    8

    Re: Displaying data from database using what i entered into a textbox, help please

    has been resolved now, i just deleted and re added the datasource and it worked, no idea why i was getting an error, must have been because i updated the database or something, thanks for your help though!

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