-
Nov 8th, 2013, 11:54 AM
#1
Thread Starter
Member
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?
-
Nov 8th, 2013, 11:58 AM
#2
Re: Need Help, Database click event
What database are you using and what version of .NET are you using?
-
Nov 8th, 2013, 11:58 AM
#3
Re: Need Help, Database click event
-
Nov 8th, 2013, 12:13 PM
#4
Thread Starter
Member
Re: Need Help, Database click event
VB 2012 and an access document
-
Nov 8th, 2013, 12:54 PM
#5
Re: Need Help, Database click event
Originally Posted by Fritztrocity1
VB 2012 and an access document
Did you do any searching online, say, Bing, Google, or Yahoo? Do you have any sample code?
-
Nov 8th, 2013, 01:12 PM
#6
Thread Starter
Member
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
-
Nov 8th, 2013, 01:13 PM
#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?
-
Nov 8th, 2013, 01:17 PM
#8
Thread Starter
Member
Re: Need Help, Database click event
to pull a row with the matching number I click from the database
-
Nov 8th, 2013, 01:22 PM
#9
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
-
Nov 8th, 2013, 01:24 PM
#10
Thread Starter
Member
Re: Need Help, Database click event
yep thats what im looking for
-
Nov 8th, 2013, 01:32 PM
#11
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
-
Nov 8th, 2013, 01:38 PM
#12
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|