473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

sql server connection error

5
i am trying to connect to a sql server using windows authentication, but getting the following errro :"sql server does not exists or access denied".pls. help:following is the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. public class mygrid : System.Web.UI.Page
  3.     {
  4.  
  5.         //SqlConnection mysqlconnect;
  6.         SqlDataAdapter mydadapt;
  7.         protected System.Web.UI.WebControls.DataGrid mygrid1;
  8.         DataSet  ds = new DataSet();
  9.  
  10.         private void Page_Load(object sender, System.EventArgs e)
  11.         {
  12.                 try
  13.          {
  14.              // Put user code to initialize the page here
  15.              string conn= "Data Source = localhost;Database=lily;Integrated Security=SSPI";
  16.             SqlConnection mysqlconnect= new SqlConnection(conn);
  17.              mysqlconnect.Open();
  18.              mydadapt = new SqlDataAdapter("Select * from Product1", mysqlconnect);
  19.              mydadapt.Fill(ds, "AllTables");
  20.  
  21.  
  22.                 mygrid1.DataSource=ds;
  23.                     mygrid1.DataBind();
  24.                      mysqlconnect.Close();
  25.  
  26.          }
  27.          catch(SqlException objsqlexception)
  28.          {
  29.              Response.Write("<ul>");
  30.              foreach(SqlError  objerror in objsqlexception.Errors)
  31.              {
  32.                  Response.Write("<li>" + objerror.Message + "</li>");
  33.              }
  34.              Response.Write("</ul>");
  35.          }
  36.             // Put user code to initialize the page here
  37.         }
  38.  
  39.             }
  40.  
  41.  
  42.  
  43.  
Jan 12 '07 #1
3 1065
bplacker
121 100+
i am trying to connect to a sql server using windows authentication, but getting the following errro :"sql server does not exists or access denied".pls. help:following is the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. public class mygrid : System.Web.UI.Page
  3.     {
  4.  
  5.         //SqlConnection mysqlconnect;
  6.         SqlDataAdapter mydadapt;
  7.         protected System.Web.UI.WebControls.DataGrid mygrid1;
  8.         DataSet  ds = new DataSet();
  9.  
  10.         private void Page_Load(object sender, System.EventArgs e)
  11.         {
  12.                 try
  13.          {
  14.              // Put user code to initialize the page here
  15.              string conn= "Data Source = localhost;Database=lily;Integrated Security=SSPI";
  16.             SqlConnection mysqlconnect= new SqlConnection(conn);
  17.              mysqlconnect.Open();
  18.              mydadapt = new SqlDataAdapter("Select * from Product1", mysqlconnect);
  19.              mydadapt.Fill(ds, "AllTables");
  20.  
  21.  
  22.                 mygrid1.DataSource=ds;
  23.                     mygrid1.DataBind();
  24.                      mysqlconnect.Close();
  25.  
  26.          }
  27.          catch(SqlException objsqlexception)
  28.          {
  29.              Response.Write("<ul>");
  30.              foreach(SqlError  objerror in objsqlexception.Errors)
  31.              {
  32.                  Response.Write("<li>" + objerror.Message + "</li>");
  33.              }
  34.              Response.Write("</ul>");
  35.          }
  36.             // Put user code to initialize the page here
  37.         }
  38.  
  39.             }
  40.  
  41.  
  42.  
  43.  
make sure you are a user with read/write rights to the database, also.. instead of saying
Database = Lily, try

Initial Catalog = Lily
Jan 12 '07 #2
plily
5
Thanks for your answer bplacker , i tried that but does not work, any other suggestions??



make sure you are a user with read/write rights to the database, also.. instead of saying
Database = Lily, try

Initial Catalog = Lily
Jan 12 '07 #3
kenobewan
4,871 Expert 4TB
Here is an example of how to set up Windows Authentication:
How to Use Windows Authentication to Access SQL Server Through a ASP.NET Web Application

Don't forget the web.config file...

Hope that this helps.
Jan 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
5
by: James | last post by:
Hello, I have written a simple logon page that redirects to another page when successful. All works fine on my computer but when I upload it I get the error message below. I have written it...
2
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
4
by: eruth | last post by:
There are loads of post on this, but nothing that seems to cover my exact problem ;) I have an ASP.Net 1.1 web application running on my local machine. I want to connect to an SQL 2005 server...
17
by: Anil Gupte | last post by:
I am using the following to try to connect to the database, but it does not seem to be working. Dim sConnString sConnString = "Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
5
by: Cirene | last post by:
I just deployed my new ASP.NET (3.5 FW) site to the hosting company I'm using, webhost4life. NOTE: I HAVE deployed other SQL Server sites to the same account with no issues. Now I'm getting...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.