The "select into" SQL statement lets you transfer data from one table to another. You use this statement in your Visual Basic applications so you can move data based on user input. The SQL statement makes it convenient for software developers to create separate tables for data on the fly. This means that you can move dynamic data to a separate table to speed up performance on tables that the database queries often.
Instructions
- 1
Click the Windows "Start" button and select "All Programs." Click "Microsoft Visual Basic," then click the VB shortcut to open the compiler. Open your project after the compiler loads.
2Insert the library files at the top of the code file. The libraries contain functions and values you use to connect to the database. Copy and paste the following code to your files:
Imports System.Data
Imports System.Data.SqlClient
3Create the database connection element. The "SQLConnection" class contains the functions needed to connect to the server. The following code is an example of a connection made by VB:
Dim sqlcon As New SqlConnection("Data Source=atisource;Initial Catalog=BillingSys;Persist Security Info=True;User ID=sa;Password=12345678")
4Create the query command. The following code shows you how to create the command and it sets up a query to transfer data from the customer table to the "mycustomers" table:
Dim query As New SqlCommand("select * from customers into mycustomers", sqlcon)
5Run the statement. The following function executes the statement and moves the data:
query.ExecuteNonQuery()
0 comments:
Post a Comment