创建更新命令的简便方法? [英] easy way of creating update commands?

查看:55
本文介绍了创建更新命令的简便方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多表要从一台服务器复制到另一台服务器。已创建新的

表以匹配旧表。我练习了一张

表。我创建了select命令(select * from tableA)和Visual

Basic .NET创建了一个更新命令 - 只要有很多

字段。


现在有更多的大表要复制。是否有一种简单的方法可以让

Visual Basic为其他表创建这些更新命令

而不必为每个表设置一个新的dataadapter?然后我就可以给它一个新的选择和更新命令并使用相同的

dataadapter。

I have lots of tables to copy from one server to another. The new
tables have been created to match the old ones. I practiced with one
table. I created the select command (select * from tableA) and Visual
Basic .NET created an update command--very long as there are a lot of
fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables
with out having to set up a new dataadapter for each table? Then I
could just assign it a new select and update command and use the same
dataadapter.

推荐答案




感谢您的帖子。


是的,* DataAdapter类只是一组数据命令和一个数据库

连接,用于填充DataSet并更新SQL Server

数据库。它包含* Command对象来做实际更新/添加/删除

等操作。


我们可以重用一个* DataAdapter类来做不同的数据库操作。

执行一个SQL命令后,我们可以将其更改为执行另一个操作

,如下所示:

* DataAdapter.UpdateCommand.CommandText = 命令文本

* DataAdapter.SelectCommand.CommandText ="命令文本"

* DataAdapter.DeleteCommand.CommandText ="命令文本"

* DataAdapter.InsertCommand .CommandText =" command text"


希望这会有所帮助


祝你好运,

Jeffrey Tan

Microsoft在线合作伙伴支持

安全! - www.microsoft.com/security

此帖子按原样提供没有保证,也没有赋予任何权利。

Hi,

Thanks for your post.

Yes, *DataAdapter class is just a set of data commands and a database
connection that are used to fill the DataSet and update a SQL Server
database. It contains *Command objects to do the actual update/add/delete
etc.. operations.

We can reuse one *DataAdapter class to do different database operations.
After doing one SQL command, we can change it to execute another operation
like this:
*DataAdapter.UpdateCommand.CommandText ="command text"
*DataAdapter.SelectCommand.CommandText ="command text"
*DataAdapter.DeleteCommand.CommandText ="command text"
*DataAdapter.InsertCommand .CommandText ="command text"

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


CJ,


除了Jeffrey。


虽然根据您提供的理由认为您的

解决方案不起作用,但我认为您的问题是否直接适用于

命令构建者。

http://msdn.microsoft.com/library/de...classtopic.asp


请注意每个向导它只适用于低于

100字段的表格。


我希望这会有所帮助,


Cor
CJ,

In addition to Jeffrey.

Although from the information that you have given the idea that your
solution will not work, does your question in my opinion directly apply the
commandbuilder.

http://msdn.microsoft.com/library/de...classtopic.asp

Be aware that as every wizard it will only work with tables with less than
100 fields.

I hope this helps,

Cor
我有很多表要从一台服务器复制到另一台服务器。创建新表
以匹配旧表。我用一张桌子练习。我创建了select命令(select * from tableA)和Visual Basic .NET
创建了一个更新命令 - 只要有很多字段。

现在有是要复制的更大的表。是否有一种简单的方法可以让Visual Basic为其他表创建这些更新命令,而不必为每个表设置一个新的dataadapter?然后我就可以给它分配一个新的选择和更新命令并使用相同的dataadapter。
I have lots of tables to copy from one server to another. The new tables
have been created to match the old ones. I practiced with one table. I
created the select command (select * from tableA) and Visual Basic .NET
created an update command--very long as there are a lot of fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables with
out having to set up a new dataadapter for each table? Then I could just
assign it a new select and update command and use the same dataadapter.



你好Jeffrey,也许我本来可以做的更好地解释我的

愿望。我在不同的

服务器上的不同数据库中有相同的表。我希望将服务器1上TableA的所有行移到服务器2上的TableA

。然后我想从表BZ移动所有行


我获得为TableA编写的代码将手动编码连接添加到

源并使用向导的向导创建sqldataadapter。

我选择使用向导作为目标,因为不像

选择声明短而甜的地方(从TableA中选择*)

插入语句非常长,因为它列出所有列名两次并且

有很多列。


我的目的是在BZ表上运行相同的代码但是我没有考虑到
考虑创建的insert命令
tableA的
对表BZ不起作用。我希望VB能让我轻松上架

并找出它'自己的表BZ的插入语句我不得不

为那些添加一个单独的sqldataadapter表格。


有没有办法做到这一点?


Jeffrey Tan [MSFT]写道:
Hi Jeffrey, Perhaps I could have done a better job of explaining my
wishes. I have identical tables in different databases on different
servers. I wish to move all the rows from TableA on Server 1 to TableA
on Server 2. Then I want to move all the rows from tables B-Z

I got the code written for TableA Adding hand coding connection to the
source and making a sqldataadapter with the wizards for the destination.
I choose to use the wizards for the destination because unlike a
select where the statement is short and sweet (select * from TableA) the
insert statement is very long as it list all the column names twice and
there are lots of columns.

My intention was to run this same code on tables B-Z as well but I
failed to take into consideration the insert command that was created
for tableA wouldn''t work on tables B-Z. I want VB to make it easy on me
and figure out it''s own insert statement for tables B-Z w/o me having to
add a seperate sqldataadapter for those tables.

Is there a way to do this?

Jeffrey Tan[MSFT] wrote:
你好,

感谢您的帖子。

是的,* DataAdapter类只是一组数据命令和数据库连接,用于填充DataSet和更新SQL Server
数据库。它包含* Command对象来进行实际的更新/添加/删除等操作。

我们可以重用一个* DataAdapter类来做不同的数据库操作。
做完之后一个SQL命令,我们可以改变它来执行另一个操作
这样:
* DataAdapter.UpdateCommand.CommandText ="命令文本"
* DataAdapter.SelectCommand.CommandText ="命令文本" ;
* DataAdapter.DeleteCommand.CommandText ="命令文本"
* DataAdapter.InsertCommand .CommandText ="命令文字"

希望这会有所帮助
Jeffrey Tan
微软在线合作伙伴支持
获得安全! - www.microsoft.com/security
此帖子提供就像没有保证,也没有赋予任何权利。
Hi,

Thanks for your post.

Yes, *DataAdapter class is just a set of data commands and a database
connection that are used to fill the DataSet and update a SQL Server
database. It contains *Command objects to do the actual update/add/delete
etc.. operations.

We can reuse one *DataAdapter class to do different database operations.
After doing one SQL command, we can change it to execute another operation
like this:
*DataAdapter.UpdateCommand.CommandText ="command text"
*DataAdapter.SelectCommand.CommandText ="command text"
*DataAdapter.DeleteCommand.CommandText ="command text"
*DataAdapter.InsertCommand .CommandText ="command text"

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.



这篇关于创建更新命令的简便方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆