从Web浏览器连接到数据时出错 [英] Error while connecting to data from web browser

查看:103
本文介绍了从Web浏览器连接到数据时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用Web应用程序

我的web.config代码是

Hi,

i am working on web application

my web.config code is

<appSettings>
    <add key="connstring" value="server=72.52.252.80;database=kandivalideal;"/>
  </appSettings>




并使用default.aspx




and on default.aspx

SqlConnection cnn = new SqlConnection();
            string connstring = System.Configuration.ConfigurationManager.AppSettings["connstring"];
            cnn = new SqlConnection(connstring);
            //cnn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            cnn.Open();
            SqlCommand cmd = new SqlCommand("select mobileno, password from register where mobileno=''" + txtmobile.Text + "''and password=''" + txtpassword.Text + "''", cnn);
            cmd.Connection = cnn;
            SqlDataReader dr = cmd.ExecuteReader();




当我从ftp上传文件并尝试从Web浏览器打开时,出现错误




when i am uploading my file from ftp and trying to to open from web browser i am getting error

Login failed for user ''''. The user is not associated with a trusted SQL Server connection.



我不明白为什么我的PC会遇到此错误,但是我在浏览器中尝试时却出现错误.

请帮助我

在此先感谢



i am not getting why i am facing this error in my pc it is working but when i am trying in browser it is giving me error.

please help me

Thanks in advance

推荐答案

您的连接字符串中有错误.您尚未为数据库登录提供用户名和密码
纠正它.
有关更多详细信息,请 www.connectionstrings.com [
There is error in your connection string. You have not given UserName and Password for database login
correct it.
for more details www.connectionstrings.com[^]


您需要在连接字符串中提供更多详细信息.检查以下链接以获取与SQL Server相关的连接字符串:

http://www.connectionstrings.com/sql-server-2005 [ http://www.connectionstrings.com/sql-server-2008 [
You need to provide some more details in the connection string. Check the following link for connection strings related to SQL server:

http://www.connectionstrings.com/sql-server-2005[^]

For SQL 2008, see the following link:

http://www.connectionstrings.com/sql-server-2008[^]


您未定义登录名&密码输入连接字符串

< appSettings>
< add key ="connstring" value ="server = 72.52.252.80; database = kandivalideal; uid = loginname; pwd = passwordforlogin"/>
</appSettings>

使用这样的连接字符串

SqlConnection cnn =新的SqlConnection();
cnn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings ["connstring"]
cnn.open

通过此连接字符串,您可以连接数据库
You missed to define login & password into connection string

<appSettings>
<add key="connstring" value="server=72.52.252.80;database=kandivalideal;uid=loginname;pwd=passwordforlogin"/>
</appSettings>

use connection string like this

SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["connstring"]
cnn.open

through this connection string you can connect with database


这篇关于从Web浏览器连接到数据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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