-
Oct 23rd, 2011, 12:01 PM
#1
Thread Starter
New Member
SQL Query Button
Is there a way to add a SQL Query Button that will run a query for me from my windows app form?
I am using VB 2010 and SQL 2008 both express. I have the form working and I am able to add customers to my customers form and the work we have done for them via the workperformed form.
I have several queries:
Phone Number Lookup
Last name Look up
Customer ID
Job ID
Stuff like that. I have been creating the DB and VB forms by myself and this is not my skill set. I do find it interesting and it is very helpful. Thanks.
-
Oct 23rd, 2011, 12:35 PM
#2
Re: SQL Query Button
Thread moved from the FAQ forum, which is not the place to post your questions.
-
Oct 23rd, 2011, 09:12 PM
#3
Re: SQL Query Button
A Button doesn't do anything other than raise its Click event. What you do when it raises that event is completely up to you. Add a Button to your form and double-click it to create a Click event handler. That's the sum total of the Button's involvement. You now put whatever code you want in the event handler. If you want to query the database then write code to query the database. If you don't know how to do that then check out the Database FAQ thread stuck at the top of this forum. Both stg and myself have links to it in our signatures.
-
Oct 24th, 2011, 06:34 PM
#4
Thread Starter
New Member
Re: SQL Query Button
Im sorry about the post in the wrong part of the forum.
I have several queries already created. I really need to make some time to research what it is that I need.
I think I have to bind to my dataset and use a gridview maybe? what you are saying sound great however I am not sure how to do that.
I have gotten this far on my own:
I created the DB, Normalized using a customerID from my customers table, created a JobID from the workperformed table.
From that I can pull info using both tables fine from within SQL Studio. Then I created the windows from app using VB. I have two one for customers where I add in their info CustomerID, FirstName, LastName, PhoneNumber, Address etc
and 1 for workperformed: JobID, CustomerID, ServiceRequests, Services etc etc
the JobID gets auto generated and so does the CustomerID. When I add new info in the app it successfully writes to the DB.
What I would like is something that helps when working on the WorkPerformed app. Like, the customer I am working with is already in my DB with a CustomerID so I will bypass the customers app and go straight to the workperformed however boy it would be nice if I new his/her customerID withough using SQL Studio, then pointing the folder icon the double clicking my query I wrote to get it.
I can figure it out on my own but I run the business and SQL / Db is not what I do. until a month ago. Thanks for any help.
-
Oct 25th, 2011, 05:07 AM
#5
Thread Starter
New Member
Re: SQL Query Button
I have followed a tutorial adding in my SQL query using a Select statement however I need to use a WHERE clause. when I use the WHERE clause it was working however I did not have a place to add my lastname. It just used the last name i added in to the SQL but no where to edit it.
SELECT * FROM dbo.customers
WHERE LastName = 'smith'
I need a drop down or something to enter in Smith.
-
Oct 25th, 2011, 05:12 AM
#6
Re: SQL Query Button
If you want the user to enter a value then you'd most likely use a TextBox. You'd use a ComboBox if you want the user to select a value. Once you've got the value, insert it into your SQL code using a parameter. To learn why and how to do that, follow the Blog link in my signature and check out my post on ADO.NET Parameters.
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
|