SQL Server中的连接字符串 [英] Connection string in SQL server

查看:148
本文介绍了SQL Server中的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有asp源代码,并且有一个数据库来存储数据(我使用sql server express 2008),它在我的本地计算机上完美运行
我使用此方法创建我的连接字符串:

Hi i have asp source code and it has a data base to store data(i use sql server express 2008), it works perfectly in my local computer
i use this method to create my connection string:

SqlConnection con = new SqlConnection("Data Source=ARASH-PC;Initial Catalog=Ranker;Integrated Security=True;Pooling=False");
con.Open();
...



我将源代码上传到服务器,现在是时候给出一个新的连接字符串了,因为我希望我的ASP站点在VPS上使用sql服务器,但是我不知道服务器上的连接字符串!我的计算机VPS上的名称是VM,所以我用了:



i uploaded my source code to my server and now it''s time to give a new connection string because i want my ASP site use sql server on my VPS.but i don''t know the connection string on my server!my computer name on VPS is VM so i used :

SqlConnection("Data Source=VM;Initial Catalog=Ranker;Integrated Security=True;Pooling=False");



并将源上传到服务器,但仍然无法打开连接并出现异常!
在我的计算机上,我使用VS2010中的服务器资源管理器查找连接字符串,但是在我的服务器上,我没有Visual Studio!我知道我的问题是一个基本的菜鸟问题,但这是我第一次尝试将源代码上传到VPS
我的错是什么?我应该如何找到连接字符串
很久很抱歉



and uploaded the source to server but it still can''t open connection and makes an exception!
on my computer i use server explorer in VS2010 to find connection string but on my server i don''t have visual studio!i know my question is a basic and rookie question but this is the first time i try to upload my source code on a VPS
What''s my mistake ? how should i find connection string
sorry for long post

推荐答案

如果您的数据库位于VPS(服务器)上,则需要与此计算机连接,而不是与VM(本地计算机)连接!
If your database is on VPS (server), you need to connnect with this computer, not with VM (local machine)!
SqlConnection("Data Source=VPS;Initial Catalog=Ranker;Integrated Security=True;Pooling=False");


正如Was Aday所写,尝试使用ip代替服务器名称.


As Was Aday wrote, try to use ip, instead of server name.


在此处查看所有类型的连接字符串 http://www.connectionstrings.com/ [ ^ ]

希望对您有帮助
see all types of connection string here http://www.connectionstrings.com/[^]

i hope it helps you


这篇关于SQL Server中的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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