根据用户需求对gridview进行不同的数据库绑定 [英] different database binding of gridview according to user demand

查看:65
本文介绍了根据用户需求对gridview进行不同的数据库绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有要求。如果有不同用户的不同数据库。当用户登录时,用户想要访问他自己的数据库和该数据库中的表。那么,我们如何根据特定的用户需求在gridview中显示不同的数据库信息。实际上我的项目是数据库管理器,它以GUI格式处理整个数据库操作。



帮助appriciated ......... thanks

Shalini

Hi,
I have a requirement. If there are different databases of different users. As a user logins, the user wants to access his own Database and the tables inside that database. So, how can we show different database information in the gridview, according to particular user need. Actually my project is database manager and it handles whole DB operations in GUI format.

An help appriciated.........thanks
Shalini

推荐答案

gridview无关紧要。您需要做的是交换连接字符串和/或SQL,具体取决于您的数据库是否位于不同的服务器上,以及它们是否具有不同的名称(显然,至少其中一个必须是这种情况)。当然,任何db代码都应该在数据层中,所以采用你现有的连接代码是很简单的事情(因为你当然只会编写代码连接到DB一次,然后访问它从那里),并动态更改连接字符串。如果数据库名称也发生了变化,那么这很好,你也可以将它放在连接字符串中。真的最重要的是,除非模式相同,否则这不会起作用,但这很明显。
The gridview is irrelevant. What you need to do, is swap out your connection string and/or SQL depending on if your databases are on different servers, and if they have different names ( clearly at least one of these things must be the case ). Of course, any db code should be in a data layer any how, so it''s a simple matter to take your existing connection code ( because of course you''d only ever write code to connect to the DB once, and then access it from there ), and have it dynamically change the connection string. If the DB name changes as well, then that''s fine, you put that in the connection string, too. Really the main thing is, this won''t work unless the schemas are the same, but that''s obvious.


这篇关于根据用户需求对gridview进行不同的数据库绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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