从一个db插入另一个db [英] Inserting from one db into another
问题描述
嗨
我已打开两个独立数据库的连接。我现在需要将一个db中的表中的
记录插入到第二个db中的表中。我该怎么办?
这样做?
谢谢
问候
从一个读取,写入另一个。
Robin S.
----- ------------------------------------------
"约翰" < Jo ** @ nospam.infovis.co.ukwrote in message
news:ug ************** @ TK2MSFTNGP02.phx.gbl ...
嗨
我已经打开了两个独立数据库的连接。我现在需要将一个db中的表中的
记录插入到第二个db中的表中。我该怎么办呢?
关于这件事吗?
谢谢
问候
你好约翰?
不需要使用两个连接:)
简单:
SqlCon.Open()
SqlDataAdapter.fill(Dataset1)
SqlCon.ChangeDatabase(" DestinationDatabase")
SqlDataAdapter.InsertCommand.CommandText = SQL查询+(数据集值)
SqlDataAdapter.InsertCommand.ExecuteNonQuery
实际上我不使用这样的代码。 (这很容易理解)
:)
" RobinS"写道:
从一个读取,写入另一个。
当然是RobinS!
''//首先它是你想要阅读的源数据库。
SqlCon.Open()
''//你已经获得数据并填充到数据集
SqlDataAdapter.fill(Dataset1)
''//然后将数据库目标更改为数据库你想写。
SqlCon.ChangeDatabase(" DestinationDatabase")
''//立即插入。
SqlDataAdapter。 InsertCommand.CommandText = SQL查询+(数据集值)
SqlDataAdapter.InsertCommand.ExecuteNonQuery
它确实有用;)
Hi
I have open connection to two separate databases. I now need to insert
records from a table in one db into a table in second db. How can I go about
doing it?
Thanks
Regards
Read from one, write to the other.
Robin S.
-----------------------------------------------
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:ug**************@TK2MSFTNGP02.phx.gbl...Hi
I have open connection to two separate databases. I now need to insert
records from a table in one db into a table in second db. How can I go
about doing it?
Thanks
Regards
Hi John?
no need use two connection :)
the simple :
SqlCon.Open()
SqlDataAdapter.fill(Dataset1)
SqlCon.ChangeDatabase("DestinationDatabase")
SqlDataAdapter.InsertCommand.CommandText = SQL Query + (Dataset value)
SqlDataAdapter.InsertCommand.ExecuteNonQuery
actually im not use code like that. ( it''s simple for you to understands)
:)
"RobinS" wrote:
Read from one, write to the other.
of course RobinS!
''// first it''s source database you want to read.
SqlCon.Open()
''// you already get the data and fill to dataset
SqlDataAdapter.fill(Dataset1)
''// Then Change database destination to database you want to write.
SqlCon.ChangeDatabase("DestinationDatabase")
''// Insert Now.
SqlDataAdapter.InsertCommand.CommandText = SQL Query + (Dataset value)
SqlDataAdapter.InsertCommand.ExecuteNonQuery
It''s really works ;)
这篇关于从一个db插入另一个db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!