sql database 2008 pass db参数 [英] sql database 2008 pass db parameter

查看:86
本文介绍了sql database 2008 pass db参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用存储过程更新sql数据库表记录.
条件-
1.将数据库名称作为参数传递
2.通过表更新,其中条件作为参数

提前谢谢!
请尽快帮助我

how to update sql database table record using stored procedure.
Condition-
1.pass database name as a parameter
2.pass the table update where condition as a parameter

Thanks in advance!
Please help me as soon as possible

推荐答案

现在有新颖性了!

您如何建议存储此过程?在哪个数据库中?因为除非将它们全部放在其中,否则您将无法访问它来选择数据库名称...

你为什么要这样做?您想解决什么问题,认为这是个好主意?
Now there is a novelty!

How do you propose to store this procedure? In which database? Because unless you put it in them all, you can''t access it to select the database name...

Why are you trying to do this? What problem are you trying to solve that you think this will be a good idea?


好吧:首先,您需要将数据库名称添加到您使用的连接字符串中(以及其他任何特定的名称).数据,例如用户名和密码).除非您尝试访问多个数据库,否则您将不想每次都这样做:即使那样,您可能也想将它们存储在配置文件中并根据需要进行访问.我相信您可以进行研究以找出答案.

其次,如果您有一个存储过程,例如(非常简单):

Okay: first you would need to add the database name to the connection string you use (plus any other specific data like user name and password). You wouldn''t want to do this every time unless you were trying to access multiple databases: even then you might want to store these in a config file and access as required. I''m sure you can do the research required to figure this out.

Second, if you have a stored procedure like (very simplistic):

create procedure UpdateWhatever (@Param1 int, @Param2 nvarchar(50))
as
    update table foo
    set Col1 = @Param2
    where Col2 = @param1
go



您的程序将使用您认为合适的任何方法将所需的参数传递给存储过程:再次进行研究:我不知道您是使用ADO还是EF还是很难说应该如何传递数据. />
ps:永远不要说尽快"或"plz hlp":只会惹恼别人.



your program would pass the required parameters to the stored procedure using whatever method you deemed appropriate: again, do your research: I have no idea if you are using ADO or EF or whatever so hard to say how you should pass the data.

ps: Never say ''as soon as possible'' or ''plz hlp'': just pisses people off.


这篇关于sql database 2008 pass db参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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