跨数据复制 [英] Copy Data across
本文介绍了跨数据复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个数据库,试图从t Users表中的某些记录中复制,我正在使用代码
I have 2 databases, Trying to copy across some records from a t Users tables, I am using the code
Dim con As SqlConnection = New SqlConnection(MyClientsConnectionString)
Dim cmd As SqlCommand
Dim conServer As SqlConnection = New SqlConnection(MyServerConnectionString)
Dim cmdServer As SqlCommand
cmd = New SqlCommand("SELECT * from TableUsers where DateJoin ='" & MyDate & "' ", con)
If con.State = ConnectionState.Closed Then con.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read = True
cmdServer = New SqlCommand("SET IDENTITY_INSERT NewTableUsers ON;INSERT Into NewTableUsers UserName,UserPassword,UserFIngerPrint,Img,Dob Values(sdr(0),sdr(1),sdr(2),sdr(3) ,sdr(4)) ;SET IDENTITY_INSERT NewTableUsers OFF", conServer)
If conServer.State = ConnectionState.Closed Then conServer.Open()
cmdServer.ExecuteNonQuery()
End While
sdr.Close()
con.Close()
conServer.Close()
用户名类型为字符串
密码是二进制(20)
img是图片
FingerPrint是varbinary(MAX)
FingerPrint is varbinary(MAX)
DOB是日期时间
那行不通
有人可以帮忙吗
推荐答案
Emadsalib:
Emadsalib :
为什么不创建一个接受datejoin参数的存储过程
并从您的前端代码中调用,并且让proc中的sql代码处理副本?
Why dont you create a stored proc which accepts datejoin parameter
and is called from your front end code and let the sql code in the proc handle the copy ?
这篇关于跨数据复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文