在webconfig中设置连接字符串 [英] Setting connection string in webconfig

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

问题描述

你好......

我在并行plesk中使用sqlserver2008,我使用用户名[moshavercity]和我的webconfig文件connectionstring属性创建数据库为[bongah],如下所示:

Hi there...
I m using sqlserver2008 in parallel plesk,i create database as [bongah] with username [moshavercity] and my webconfig file connectionstring attribute as below:

<connectionStrings>
    <add name="bongahConnectionString" connectionString="Data Source=.\SqlExpress;Initial Catalog=bongah;
User Id=moshavercity; Password=mehdi1363224MEH1363"
      providerName="System.Data.SqlClient" />
  </connectionStrings>



但当我尝试登录db时出现此错误


but when i try to login to db this error appear

Login failed for user 'moshavercity'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'moshavercity'.

Source Error: 


Line 78:     {
Line 79:         SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["bongahConnectionString"].ToString());
Line 80:         con.Open();
Line 81:         str





我该如何解决这个问题问题,请



how can i fix this problem,please

推荐答案

请先阅读我对这个问题的评论。



看看这里:

ASP的SQL Server连接字符串。 NET Web应用程序 [ ^ ]

如何:从Web.config文件中读取连接字符串 [ ^ ]

您可以在此处找到的示例连接字符串:http://www.connectionstrings.com/ [ ^ ]
Please, read my comment to the question first.

Have a look here:
SQL Server Connection Strings for ASP.NET Web Applications[^]
How to: Read Connection Strings from the Web.config File[^]
Sample connection strings you'll find here: http://www.connectionstrings.com/[^]


您使用用户名[moshavecity]创建了一个数据库,但您使用的是用户ID = moshave r 城市?



可能是问题吗?







Op改变了问题以反映相同的拼写。见解决方案2.
You created a database with username [moshavecity] but you are using User ID = moshavercity ?

Might that be the problem?

:

Op changed the question to reflect same spelling. See Solution 2.


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

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