开发者

Insert INTO in vb.net

I have 2 d开发者_高级运维atabases. In first one I have 10 tables. Second one is only 1 table. I would like to select 1 columns from each table from 1st database and Insert INTO another database. How can I manage this using INSERT INTO statement in VB.net?


I deleted my previous answer saying that you have to manually copy over the data. For now, let's assume you want to do this with a SELECT INTO statement.

The following code shows you how to execute a SQL command on your database using a ADO.NET connection and command object:

' Open a connection to your database (e.g. in a SQL Server): '
Using connection As IDbConnection = New SqlConnection("<Connection string>")
    connection.Open()
    Try

        ' Define the SQL command to be executed here: '
        Dim command As IDbCommand = connection.CreateCommand()
        command.CommandText = "SELECT <...> INTO <...>"

        ' Execute the command: '
        command.ExecuteNonQuery()

    Finally
        connection.Close()
    End Try
End Using


I hope this helps:

From sql side, you'll just need to write a stored procedure to insert into (ten) hash tables and select/insert them into your target table.

In Vb.net, you'll need: a connection object and a command object to call your stored procedure

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜