当前位置:编程学习 > C#/ASP.NET >>

请高手解释一下!.net

Data Source=.\SQLEXPRESS;AttachDbFilename=F:\c#\WebSite1\App_Data\Database.mdf;Integrated Security=True;User Instance=True
答案:Data Source服务器
AttachDbFilename数据库名
Integrated Security=True使用Windows验证的方式去连接到数据库服务器
User Instance=True使用用户实例
其他:在 .net 中Initial Catalog 数据名,用AttachDbFilename :路径不太好吧,如果是日志或什么写下决定路径也蛮不错 一般有一下几种连接数据库的方法: 
1. public const string CONN_STRING = "Data Source=.;Initial Catalog=myBlog;User ID=sa;Pwd=sa";
2.  public const string CONN_STRING = "server=.;database=myBlog;uid=sa;pwd=sa";
3.在Web.Config中配置
要在<configuration>节点下面添加
<appSettings>
    <add key="ConnectionString" value="server=LIMINGTECH-GUO;database=SecurMass;uid=sa;pwd=sa" />
    </appSettings>
在类里面这样调用:
 public static readonly string ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
祝你好运! 

上一个:高手来,asp.net中xsc xsd xss csproj pdb这些文件分别是干什么的啊? 都是要自己写的吗?
下一个:页面中"跳过这一步"的代码,.net

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,