连接到服务器上的数据库 [英] connect to database on server

查看:76
本文介绍了连接到服务器上的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有C#应用程序,并且想连接到其他计算机上的SQL Server.我在数据库中使用了字符串连接,并将其放在我的应用程序中,但这没用吗?

hello,

I''ve c# app ,and I want to connect to sql server on other computer. I used the string connection in the database and put it in my app, but it didn''t work? Also there''re connected through switch?

推荐答案

您确定您的连接字符串正确吗?交换机不会妨碍您访问数据库,但是路由器,防火墙可以.
-检查是否为服务器实例启用了TCP/IP连接
-在客户端和服务器之间的整个跃点中检查防火墙设置
-使用其他工具检查连接
Are you sure your connection string is correct? A switch won''t hinder you in accessing the database, but a router, a firewall could.
- Check if the TCP/IP connections is enabled for the server instance
- Check the firewall setting throughout the hops between the client and the server
- Check the connection with an other tool


从远程PC连接SQL Server
1. share your database on LAN/WAN
2. set new connection string in exe/text file [where sql connection string is written]
 
step 1: follow steps given in this link [For access sql database remotely(from different pcs)]
http://support.microsoft.com/kb/914277[^]
 
step 2: after step 1 complete then change connection string's parameters, 
datasource = server-name OR IP-Address [which is in sharing now after step 1] ;
Initial catalog = your database name ;
UserId = sql server - user login Id ;
Password = sql server - user login password;




如果出现错误(错误号: 18456 )-无法从远程PC连接在域中找不到用户
原因:用户锁定(状态1)
sql server不包含这样的loginName ...
此用户名(例如sa)未在此服务器名称内创建
解决方案:在sql服务器中创建新登录名-(使用SQL身份验证模式)


创建新的SQL Server身份验证用户登录名




If error comes (err No: 18456) - can not connect from remote pc User not found in Domain
Reason : UserLock out (state-1)
sql server does not contain loginName like this...
this username(e.g. sa) is not created inside this server-name
Solution : create New Login in sql server-(With SQL authentication Mode)


Create New SQL Server Authenticate user login

sql -> object explorer ->security -> logins-> new login->

in new window
general tab-> Login name : abcd
                        check 'Sql server authentication'
                        Pwd =*** , confirm pwd=***
                        check 'Enforce pwd policy'
                        DO NOT check 'Enforce pwd expiration' (if check it will cause err: 18515)
Ok.
.
.
.
now, try to login
.
If err comes (err No: 18452)

solution : For sql 2000
                         start -> Program ->  sql server  -> enterprise Manager ->
                         server name -> properties ->security under authentication,
                         check 'Sql server & Windows'
           For sql 2005
                        sql -> servernm -> properties -> security ->
                        check 'Sql server & window Authentication mode'
Note: stop sql server & Agent services then start both services again.
     
Now disconnect sql server & connect again you will also able to Login through sql-authentication



祝您编码愉快!
:)



Happy Coding!
:)


这篇关于连接到服务器上的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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