How can i add one record from a table to another table in vb.net?
Whats the instruction ?Using the instructions of squel , how can i put in the vb.net instructions?
ehsan2
Ok ehsan2, VB is just as easy as the SQL side. First, you can either write a Stored Procedure with this SQL code in SQL Server or you can hard code it in VB.Net. The latter is a more eligant way, but each to his own.
I assume you know how to connect to an SQL Database and Retrieve records with ADO.Net already (especially with the question you have asked being a moderate level task).
1. Create your Connection String
2. Create your Command Object
3. Create the SQL String (i.e. the Insert Select Statement) unless you are using a stored procedure
4. Pass sqlString and Connection object to Command
5. Open the Connection
7. ExecuteNonQuery Method of the Command Object and voila!
Example:
Dim myCommand As New SqlCommand(myExecuteQuery, myConnection)
myCommand.Connection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()