探讨如何配置SQL2008,让其允许C#远程外部连接的方法详解
时间:2024-01-23 10:51:09
Step 1:在服务器图标上单击右键,选择property,然后选connection,把allow remote connection选上,这一步的目的是让数据库允许远程连接。
Step 2:在数据库服务器图标上,展开目录,找到Security下的Logins子目录树,设置SA账户的属性,改password,在status栏里,login选上enable。这一步的目的是,允许远程客户端使用sa用户邓肯,sa是system administrator的缩写,拥有数据库最高管理权限,默认状态下是禁用的。
Step3:在数据库服务器图标上右键,打开Facets选项把RemoteDacEnabled的value改成true。这一步的目的是允许建立远程专用管理员连接,此种连接拥有最高权限,即使无法建立标准连接,也可以建立DAC连接。
Step4:开启服务,打开SQL Server Configuration Tool,打开网络配置,选择TCP/IP协议,点开属性,IP地址填数据库所在服务器的IP地址,如果是本地服务器,填127.0.0.1。
测试方法:
建立一个C# Console application源文件,代码如下:
class Program
{
static void Main(string[] args)
{
SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=123456789;database=MyTable");
try
{
con.Open();
Console.WriteLine("连接数据库成功");
}
catch
{
Console.WriteLine("无法连接数据库");
}
Console.ReadKey();
}
}
如果能正常连接,则会提示连接成功。
标签:远程连接sql2008
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Makefile构建Golang项目示例详解
2024-05-25 15:16:26
python使用opencv切割图片白边
2021-10-16 04:44:06
![](https://img.aspxhome.com/file/2023/9/128509_0s.jpg)
vue文件树组件使用详解
2024-05-09 09:53:52
python工具模块介绍之time 时间访问和转换的示例代码
2023-11-08 08:02:14
pandas 实现某一列分组,其他列合并成list
2022-06-12 13:49:21
![](https://img.aspxhome.com/file/2023/8/95578_0s.jpg)
Microsoft Access项目不能压缩的原因
2008-11-28 14:48:00
详解MySQL性能优化(一)
2024-01-18 11:39:52
![](https://img.aspxhome.com/file/2023/4/75634_0s.jpg)
设计师的职业规划
2009-08-31 12:52:00
Python环境搭建过程从安装到Hello World
2023-03-03 07:41:36
![](https://img.aspxhome.com/file/2023/6/117976_0s.png)
pytorch教程resnet.py的实现文件源码分析
2023-11-07 21:18:47
![](https://img.aspxhome.com/file/2023/7/75107_0s.png)
Python完全识别验证码自动登录实例详解
2023-12-17 03:58:14
django基础学习之send_mail功能
2023-04-01 00:16:53
python单元测试框架pytest介绍
2021-06-11 15:28:55
![](https://img.aspxhome.com/file/2023/8/67268_0s.png)
Python numpy下几种fft函数的使用方式
2022-06-21 07:19:55
![](https://img.aspxhome.com/file/2023/0/107180_0s.png)
基于FlashPaper实现JSP在线阅读代码示例
2023-06-14 21:02:31
Python中的字典及其使用方法
2022-03-22 13:31:49
![](https://img.aspxhome.com/file/2023/3/93673_0s.png)
使用Python通过win32 COM打开Excel并添加Sheet的方法
2021-12-07 11:53:34
![](https://img.aspxhome.com/file/2023/5/114625_0s.jpg)
完美解决python3.7 pip升级 拒绝访问问题
2023-08-10 07:45:33
![](https://img.aspxhome.com/file/2023/6/128626_0s.png)
MySQL索引之聚集索引介绍
2024-01-24 10:02:44
![](https://img.aspxhome.com/file/2023/9/124499_0s.jpg)
完美的渐变透明效果,支持Firefox
2008-06-18 18:18:00