VB.NET,ASP.NET中的更新命令 [英] UPDATE COMMAND IN VB.NET,ASP.NET
问题描述
大家好,
当我突然遇到这个问题时,我的程序运行良好.
我不知道该怎么做我需要完成的下一个功能.
我已经完成了插入值,显示gridview等的工作,并且效果很好.现在我的问题是更新命令.
我有2张桌子
表:
tblDest
字段:
destLastName
destFname
destEmail
表: tblSource
字段:
姓氏
SourceFname
来源Emai
现在,当我在sql server中运行我的update命令时,它的效果很好!我只需右键单击数据库,单击新查询,然后运行以下命令:
hi Everyone,
My program is doing good when I suddenly bumped into this problem.
I dont know how to do the next functionality that I need to accomplish.
I am done with inserting values, showing the gridview etc and it works great. Now my problem is the update command.
I have 2 tables
table:
tblDest
Fields:
destLastName
destFname
destEmail
Table: tblSource
Fields:
Sourcelastname
SourceFname
SourceEmai
Now, when I run my update command in sql server, it works great! I just right click the database, click new query and i run this command:
update tblDest set DestEmail =(Select SourceEmail from tblSource where tblSource.SourceFname = tblDest.DestFname and tblSource.SourceLastname = tblDest.DestLastname)
该查询的作用是更新表tbldest中两个相等的表中存在姓氏和名字的电子邮件,
问题是,我想使它自动化,我已经完成了插入值的工作,问题是,我不知道如何运行更新命令,
我尝试这样做:
what the query does, is it updates the table tbldest email where lastname and firstname exists in both tables that are equal,
the question is, I want to automate this, I am done with inserting values, the problem is, I dont know how to run the update command,
I tried doing this:
Dim sqlds As New SqlDataSource
sqlds.ConnectionString = ConfigurationManager.ConnectionStrings("sqlconnect").ConnectionString
sqlds.ProviderName = ConfigurationManager.ConnectionStrings("sqlconnect").ProviderName
sqlds.UpdateCommand = "update tblDest set DestEmail =(Select SourceEmail from tblSource where tblSource.SourceFname = tblDest.DestFname and tblSource.SourceLastname = tblDest.DestLastname)"
DestGrid.DataSource = sqlds
DestGrid.DataBind()
,但是什么也没发生.
我要在此先感谢大家的帮助.
but nothing happened.
I want to thank you guys in advance for any help.
推荐答案
(可能)最简单的更新方法是使用ExecuteNonQuery [
The (possibly) simplest way to do an update is to use ExecuteNonQuery[^].
我不知道您是什么问题是,但我认为您可以尝试此[^]
祝你好运
i dont know what your problem is but i think you can try this[^]
Good Luck
这篇关于VB.NET,ASP.NET中的更新命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!