把我的SQL数据库上传到空间后在web.config里的连接字符串怎么改?_百 ...

发布网友 发布时间:2024-10-22 02:53

我来回答

3个回答

热心网友 时间:2024-11-10 09:49

如果是SQLExpress版本,直接使用信任的连接和数据文件连接串.

如果不是,则你需要请服务器的管理员告诉你你可以使用的id和密码(一般是要钱的,而且不太便宜)

ODBC连接串各种格式:
1 标准安全
Driver={SQL Native Client};Server=地址;Database=mydb;Uid=sa;Pwd=sa;
2 信任安全
Driver={SQL Native Client};Server=地址;Database=mydb;Trusted_Connection=yes;
3 带实例名连接
Driver={SQL Native Client};Server=地址\实例名;Database=mydb;Trusted_Connection=yes;
4 多活动结果集(只支持.Net 2.0以上)
Driver={SQL Native Client};Server=地址;Database=mydb;Trusted_Connection=yes;MARS_Connection=yes;
5 加密传输
Driver={SQL Native Client};Server=地址;Database=mydb;Trusted_Connection=yes;Encrypt=yes;
6 SQLExpress版
Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
7 SQLExpress版(只支持ASP.NET 2.0并且是放在App_Data文件夹里)
Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|文件名.mdf; Database=dbname;Trusted_Connection=Yes;
8 数据镜像 只支持ADO.NET
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;

OldDB对应连接格式(不想打那么多字,只写编号,看上面就行了)
1 Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
2
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
3
Provider=SQLNCLI;Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=yes;
4
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;MarsConn=yes;
5
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;
6
Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
7
Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
8
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;

微软专用的SqlConnection格式:
1 标准安全
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
2 标准安全2(一样)
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
3 信任连接
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
4 信任连接2(一样的)
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
5 带实例名
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
6 从PDA和手机连接数据库
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;
7 带ip地址和端口
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
8 多活动结果集
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;MultipleActiveResultSets=true;
9 SQLExpress
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
10 SQLExpress板App_Data文件夹
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
11 带实例名的本地数据库
Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
12 数据镜像
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;
13 支持异步
Server=myServerAddress;Database=myDataBase;Integrated Security=True;Asynchronous Processing=True;

热心网友 时间:2024-11-10 09:48

把server改域名或IP

热心网友 时间:2024-11-10 09:50

直接把.config的ip改成服务器ip,用户与密码要改一下把。
然后覆盖到服务器上就ok

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com