How to Create & Save a Query in Visual Basic

104 5
    • 1). Open your developer environment. Click on "Open" next to "Project" or "Web Site" depending on what type of project you are working on. If you have not started a project yet, you can still bind your database to the project before you begin building the rest of your application. Click on "Create" next to "Project" if you need to start from scratch and then choose "Windows Form Application" from the menu choices. Name your project and type the name in the "Name" field down below your choice. Click "OK" to finish.

    • 2). Locate the top menu choices and click on the word "Data." Scroll down and choose "Add New Data Source." Follow the screen prompts to complete adding the database to the application. The box will close when you finish adding the database.

    • 3). Navigate to the top menu choices again and click on "Data." This time, choose, "Add Query" and a new box will open showing you the default fields from the you database added that will display once you run your program. Click on the bottom box, "Query Builder." The query builder window will open.

    • 4). Expand the query-building window so you can see all the fields and functions available. In the top section will be your database field options. Unclick any fields you do not want to have sorted.

    • 5). Drop down the next section when you are satisfied with what you want to sort. This section will allow you to choose how you want these items displayed. For example, say you have a list of people with names, addresses, cities and phone numbers and you want to build a query displaying everyone by first names in ascending alphabetic order. Start at the first line and make sure "Output" is checked and choose an option from the drop down boxes in "Sort Type" and "Sort Order." The pane below this will show the actual query statements the query builder is making for you.

    • 6). Click "Execute Query" to test the query. The results will display in the bottom section of the query builder window. Click "OK" when you are finished which returns you to the "Search Builder Criteria" window. Click "OK" on this window as well. You have just created and saved a query with Visual Basic.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.