内部&外部程序... [英] Internal & external program...

查看:126
本文介绍了内部&外部程序...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.net的新手,并希望创建一个Windows窗体程序,供我们的内部用户用来直接访问SQL Server或将其发送给网络外的用户,而这些用户将改用SQL Server Compact Edition.该程序检查它是否有权访问SQL Server,然后再连接到它(如果有的话),然后再连接到SQL Server Compact数据库的最佳方法是什么?

谢谢

New to .net and wishing to create one windows form program that can be used by our internal users to directly access a SQL Server or sent to users outside our network that would instead use SQL Server Compact Edition. What would be the best way for the program to check if it has access to SQL Server and then connect to it if it does or if it does not, then connect to a SQL Server Compact database?

Thanks

推荐答案

您可以执行以下操作:
You can do this:
SqlDataSourceEnumerator sdse = SqlDataSourceEnumerator.Instance;
DataTable dt = sdse.GetDataSources();
Console.WriteLine("Avalaiable sources:");
foreach (DataRow dr in dt.Rows)
    {
    Console.WriteLine(dr["ServerName"]);
    }

如果您的服务器在列表中,则可用.
注意:您可能要在后台任务中执行此操作:扫描网络需要花费几秒钟.

If your server is in the list, it''s available.
Note: you might want to do this in a background task: it takes a some seconds to scan your network.


这篇关于内部&外部程序...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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