开发者

Remote connect to SQL server - trusted connection, windows credentials

开发者 https://www.devze.com 2022-12-25 02:01 出处:网络
Sorry for the confusing name, I did not know of better one. There is a network with SQL 2005 server. I am provided with the windows account information to this computer so I can use remote desktop or

Sorry for the confusing name, I did not know of better one. There is a network with SQL 2005 server. I am provided with the windows account information to this computer so I can use remote desktop or map its drives. The SQL uses trusted connection. I am thinking whether I can connect remotely only to the开发者_JAVA技巧 SQL server? Thanks


This is based on my experience with SQL Server, but may not be entirely complete in scope.

SQL Server Manager will let you connect to the server instance with windows credentials, but to access the database tables you will need to create a login within SQL Server. Using SQL Server Manager, you can do this under the Security folder of the hierarchy of objects in the left column.

Next you will need to create a database (if one doesn't already exist that you are interested in using) and in that database's Security folder, create a user that corresponds to the login. When doing this you will also need to assign the permissions of the user (select, insert, delete, etc.).

Once that is complete, you can access the server anywhere on the network with the appropriate credentials, but you will need to make sure that there are no blocked ports, etc. from a network perspective.

In C# the statement to create a new connection looks like this:

SqlConnection conn = new SqlConnection("user id = username; " +
    "password = secret; " +
    "server = servername\sqlexpress; " +
    "database = databasename; " +
    "connection timeout = 30");

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号