我想把数据源1内的数据赚到数据源2 执行了,但是数据没有复制过去,应该咋改? 表是一模一样的结构.
Dim cmd As New SQLCommand
cmd.C o n n e c t i o n N a m e = "数据源1"
Dim cmd2 As New SQLCommand
cmd2.C o n n e c t i o n N a m e = "数据源2"
Dim dt As DataTable
Dim lst As List(Of String)
lst = Connections("数据源1").GetTableNames
For Each nm As String In lst
cmd.CommandText = "SELECT * From {" & nm & " }"
dt = cmd.ExecuteReader()
For Each dr As DataRow In dt.DataRows
For Each dc As DataCol In dt.DataCols
cmd2.CommandText = "Insert Into " & nm & " (" & dc.Name & ") Values (" & dr(dc.Name) & ")"
cmd2.ExecuteReader()
Next
Next
Next
MessageBox.Show("成功")
[此贴子已经被作者于2012-8-25 23:07:52编辑过]