帮助连接字符串问题 [英] help with connection string problem

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

问题描述


我在我的机器上安装了完整版的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

推荐答案

原因可能是,您在代码中使用的DataSource控件可能引用了名为"LocalSqlServer"的ConnectionString设置.
检查您的实现位置,您指的是什么键.

我注意到的要点:
IMO两个连接字符串均不应正常使用,因为它的构造不正确.

The reason could be, your DataSource control which you use in the code might referring to the ConnectionString setting named "LocalSqlServer".

Check your implementation place what key you are referring to.

Point I noticed:
IMO both connection string should not work as it is not constructed properly.

<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)


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

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