问题描述
我在我的机器上安装了完整版的sql server 2005,我试图在web.config文件中添加连接字符串,例如
Hi,
I have full version of sql server 2005 installed on my machine i am trying to add connection string in web.config file like this
<add name="myconnectionstring";connectionString="data source=.;DataBase=mydatabase;Uid=user;Pwd=password" />
但它无法正常工作,则无法连接.
当我尝试这样
but its not working it doesn''t connects.
When i tried like this
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer";connectionString="data source=.;DataBase=mydatabase;Uid=user;Pwd=password"/>
它起作用了,但是我想知道为什么它不能与上面的我自己的连接字符串一起起作用.
致谢
it worked but i want to know why its not working with my own connection string name like above.
Thanks and regards
推荐答案
<add name="LocalSqlServer";
您不应该在add
标记中的名称属性旁边放置"; ".
You should not put ";" next to name attribute in the add
tag.
<connectionStrings>
<add name="OsmEmpConString" connectionString="Data Source=.\sqlexpress;Initial Catalog=AgentDB; User ID= Sqluser ; Password= Change;"
providerName="System.Data.SqlClient" />
</connectionStrings>
DataSource =您的数据库源
初始目录=数据库名称
用户ID =数据库的用户ID
密码=数据库密码
DataSource = Your database source
Initial Catalog = Database name
User ID = User id of the database
Password = Password to the database
<connectionStrings>
<add name="connection_string" connectionString="server=YOUR_PC_NAME_OR_SERVER_NAME; database=DATABASE_NAME; integrated security=true"/>
</connectionString>
它的工作原理(经测试的代码)
IT WORKS (TESTED CODE)
这篇关于帮助连接字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!