Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Trouble connecting to SQL Server with ASP.NET web application

Trouble connecting to SQL Server with ASP.NET web application

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelpasp-netsql-server
4 Posts 3 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chubbysilk
    wrote on last edited by
    #1

    Hello, I am attempting to retrieve data from a database on a SQL server. This data will them be displayed on my web page. For some reason, everytime I attempt to view the web page, I get the following error: "SQL Server does not exist or access denied." I am positive that my machine has access to the server and that the user name and password are correct. I have tested this several times through Enterprise Manager and through the "Connect To Database" option in Visual Studio. It just doesn't work through the web application. Here is part of my code: protected System.Data.SqlClient.SqlConnection sqlserver; sqlserver.ConnectionString = "Data Source=12.34.56.78; User ID=sa; password=*****; Initial Catalog=Global; Integrated Security=false"; sqlserver.Open(); // the code to fill the dataset goes here sqlserver.Close(); I have attempted to connected to several different servers, which I know I have access to, but I keep getting the same error. This is not happening to anyone else with access. Is there a setting on my machine that is making this happen? Any ideas would be much appreciated. Thanks for your help, RC

    S N 2 Replies Last reply
    0
    • C chubbysilk

      Hello, I am attempting to retrieve data from a database on a SQL server. This data will them be displayed on my web page. For some reason, everytime I attempt to view the web page, I get the following error: "SQL Server does not exist or access denied." I am positive that my machine has access to the server and that the user name and password are correct. I have tested this several times through Enterprise Manager and through the "Connect To Database" option in Visual Studio. It just doesn't work through the web application. Here is part of my code: protected System.Data.SqlClient.SqlConnection sqlserver; sqlserver.ConnectionString = "Data Source=12.34.56.78; User ID=sa; password=*****; Initial Catalog=Global; Integrated Security=false"; sqlserver.Open(); // the code to fill the dataset goes here sqlserver.Close(); I have attempted to connected to several different servers, which I know I have access to, but I keep getting the same error. This is not happening to anyone else with access. Is there a setting on my machine that is making this happen? Any ideas would be much appreciated. Thanks for your help, RC

      S Offline
      S Offline
      Steve McLenithan
      wrote on last edited by
      #2

      Try adding:

      Trusted_Connection=false;

      to your connection string.

      // Steve McLenithan

      Cluelessnes:
         There are no stupid questions, but there are a lot of inquisitive idiots.

      C 1 Reply Last reply
      0
      • S Steve McLenithan

        Try adding:

        Trusted_Connection=false;

        to your connection string.

        // Steve McLenithan

        Cluelessnes:
           There are no stupid questions, but there are a lot of inquisitive idiots.

        C Offline
        C Offline
        chubbysilk
        wrote on last edited by
        #3

        I tried "Trusted_Connection=false" and got the same error. But thanks for the suggestion.

        1 Reply Last reply
        0
        • C chubbysilk

          Hello, I am attempting to retrieve data from a database on a SQL server. This data will them be displayed on my web page. For some reason, everytime I attempt to view the web page, I get the following error: "SQL Server does not exist or access denied." I am positive that my machine has access to the server and that the user name and password are correct. I have tested this several times through Enterprise Manager and through the "Connect To Database" option in Visual Studio. It just doesn't work through the web application. Here is part of my code: protected System.Data.SqlClient.SqlConnection sqlserver; sqlserver.ConnectionString = "Data Source=12.34.56.78; User ID=sa; password=*****; Initial Catalog=Global; Integrated Security=false"; sqlserver.Open(); // the code to fill the dataset goes here sqlserver.Close(); I have attempted to connected to several different servers, which I know I have access to, but I keep getting the same error. This is not happening to anyone else with access. Is there a setting on my machine that is making this happen? Any ideas would be much appreciated. Thanks for your help, RC

          N Offline
          N Offline
          neha12
          wrote on last edited by
          #4

          Yes u will get this type of problem if ur SQL server is not running , but as u said that its running then we dont have to bother about that I did the same thing but I did not face any problem. Try using this connectivity approach. conn = New SqlConnection("data source=.;initial catalog = d/b name;integrated security=SSPI;persist security info=False;workstation id=" + System.Net.Dns.GetHostName + ";packet size=4096") comm = New SqlCommand("Select * from table_name") Conn.Open() Comm.Connection = Conn Reader = Comm.ExecuteReader While Reader.Read DropDownList1.Items.Add(reader.GetValue(0).ToString) End While

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups