Results 1 to 12 of 12

Thread: Need Help, Database click event

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    50

    Need Help, Database click event

    I need to have Labels pull up a row of information from my database when clicked on. Whats the most simple code to accomplish that?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Need Help, Database click event

    What database are you using and what version of .NET are you using?

  3. #3

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    50

    Re: Need Help, Database click event

    VB 2012 and an access document

  5. #5

    Re: Need Help, Database click event

    Quote Originally Posted by Fritztrocity1 View Post
    VB 2012 and an access document
    Did you do any searching online, say, Bing, Google, or Yahoo? Do you have any sample code?

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    50

    Re: Need Help, Database click event

    I have. I have some code for the label to click, but it doesnt pull up a window with the database information, and im pretty sure it wont just pull up the row i want, it will pull up the whole database which I dont want.

    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

    dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
    dbSource = "Data Source = R:/DBASE/compn.mdb"

    con.ConnectionString = dbProvider & dbSource

    con.Open()

    sql = "SELECT * FROM Computer"
    da = New OleDb.OleDbDataAdapter(sql, con)
    da.Fill(ds, "compn")

    End Sub

  7. #7

    Re: Need Help, Database click event

    Well yeah, your query is doing exactly what it's been told to do: Give me everything from 'Computer'. What are you expecting it to do?

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    50

    Re: Need Help, Database click event

    to pull a row with the matching number I click from the database

  9. #9
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Need Help, Database click event

    I dont quite understand. Do you have a set of fixed labels with numbers, and when you click one of those you want to display the single record of the database that matches that number?
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  10. #10

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    50

    Re: Need Help, Database click event

    yep thats what im looking for

  11. #11
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Need Help, Database click event

    If you are coding it something like the example you gave, change the SQL Statement to include the WHERE clause. It would be something like;

    SELECT * FROM Computer WHERE keyField = Label.Text

    Of course this is just a direction to take, cant use controls inside the SQL Statement and you should use parameters. But following this could get you there.
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  12. #12

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    50

    Re: Need Help, Database click event

    Do I need to add a MsgBox code in order for a window to pop up when i click the label?

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