Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i am working on web application

my web.config code is

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



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



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.


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
Posted

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[^]
 
Share this answer
 
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[^]
 
Share this answer
 
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
 
Share this answer
 
Comments
aayu 21-Dec-11 0:02am    
did the changes same error
aayu 21-Dec-11 0:02am    
can you tell me how to import my table on the server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900