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. Database & SysAdmin
  3. Database
  4. SqlConnection problem on ASP.NET Web Application

SqlConnection problem on ASP.NET Web Application

Scheduled Pinned Locked Moved Database
helpdatabasecsharpasp-netsql-server
12 Posts 5 Posters 0 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 Colin Angus Mackay

    Possible reasons. 1. The server won't allow you to connect using that Data Source becuase the datasource indicates that TCP/IP is used. * Use a datasource name that does not require TCP/IP * Set up SQL Server to permit TCP/IP connections. 2. The user name or password is incorrect. * Check the user name and password combination is correct * Use a trusted connection instead

    Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Different ways to add point data in SQL Server 2008 * Spatial References in SQL Server 2008 My website |

    L Offline
    L Offline
    laziale
    wrote on last edited by
    #3

    what if I don't have any password?? What should I use for password?? One more think: When I am writing the data source like this: "Data Source=.\SQLEXPRESS" it gives me a error and it says: "Unrecognized escape sequence", and when I am turning the slash otherway: "Data Source=./SQLEXPRESS" it says is ok. Does that make any difference??? Thanks for the help

    C 1 Reply Last reply
    0
    • L laziale

      what if I don't have any password?? What should I use for password?? One more think: When I am writing the data source like this: "Data Source=.\SQLEXPRESS" it gives me a error and it says: "Unrecognized escape sequence", and when I am turning the slash otherway: "Data Source=./SQLEXPRESS" it says is ok. Does that make any difference??? Thanks for the help

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #4

      laziale wrote:

      what if I don't have any password?? What should I use for password??

      As I said already - Use a trusted connection instead. See http://www.connectionstrings.com/[^]

      laziale wrote:

      When I am writing the data source like this: "Data Source=.\SQLEXPRESS" it gives me a error and it says: "Unrecognized escape sequence", and when I am turning the slash otherway: "Data Source=./SQLEXPRESS" it says is ok. Does that make any difference???

      Ummm... Yes. Why explain what the difference is, then ask me if there is a difference?

      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Different ways to add point data in SQL Server 2008 * Spatial References in SQL Server 2008 My website |

      L 1 Reply Last reply
      0
      • C Colin Angus Mackay

        laziale wrote:

        what if I don't have any password?? What should I use for password??

        As I said already - Use a trusted connection instead. See http://www.connectionstrings.com/[^]

        laziale wrote:

        When I am writing the data source like this: "Data Source=.\SQLEXPRESS" it gives me a error and it says: "Unrecognized escape sequence", and when I am turning the slash otherway: "Data Source=./SQLEXPRESS" it says is ok. Does that make any difference???

        Ummm... Yes. Why explain what the difference is, then ask me if there is a difference?

        Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Different ways to add point data in SQL Server 2008 * Spatial References in SQL Server 2008 My website |

        L Offline
        L Offline
        laziale
        wrote on last edited by
        #5

        well, I did my connection now as: "Data Source=./SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\angel.MMB\My Documents\Visual Studio 2005\WebSites\WebSite2App_Data\test2.mdf;Trusted_Connection=true" and the connectionString now is same in the OnClick event of the button and in the web config with the only difference that in the web config file I have

        Y 1 Reply Last reply
        0
        • L laziale

          well, I did my connection now as: "Data Source=./SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\angel.MMB\My Documents\Visual Studio 2005\WebSites\WebSite2App_Data\test2.mdf;Trusted_Connection=true" and the connectionString now is same in the OnClick event of the button and in the web config with the only difference that in the web config file I have

          Y Offline
          Y Offline
          yogesh_kumar_agarwal
          wrote on last edited by
          #6

          Hi laziale i want to know did you are using msaccess as backend??? Yogesh Agarwal

          P L 2 Replies Last reply
          0
          • Y yogesh_kumar_agarwal

            Hi laziale i want to know did you are using msaccess as backend??? Yogesh Agarwal

            P Offline
            P Offline
            pmarfleet
            wrote on last edited by
            #7

            yogesh_kumar_agarwal wrote:

            i want to know did you are using msaccess as backend???

            Obviously he isn't. His previous post indicated that he was using the Express edition of SQL Server.

            Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

            Y 1 Reply Last reply
            0
            • P pmarfleet

              yogesh_kumar_agarwal wrote:

              i want to know did you are using msaccess as backend???

              Obviously he isn't. His previous post indicated that he was using the Express edition of SQL Server.

              Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

              Y Offline
              Y Offline
              yogesh_kumar_agarwal
              wrote on last edited by
              #8

              i think you didn't read the connection string properly he tries to connect with a mdb database file means Access Yogesh Agarwal

              P 1 Reply Last reply
              0
              • Y yogesh_kumar_agarwal

                Hi laziale i want to know did you are using msaccess as backend??? Yogesh Agarwal

                L Offline
                L Offline
                laziale
                wrote on last edited by
                #9

                No, I am using SQL Server 2005

                1 Reply Last reply
                0
                • Y yogesh_kumar_agarwal

                  i think you didn't read the connection string properly he tries to connect with a mdb database file means Access Yogesh Agarwal

                  P Offline
                  P Offline
                  pmarfleet
                  wrote on last edited by
                  #10

                  yogesh_kumar_agarwal wrote:

                  i think you didn't read the connection string properly he tries to connect with a mdb database file means Access

                  No, you didn't read the connection string properly. The database file he was trying to connect to had a .mdf extension, not a .mdb extension. This is consistent with trying to connect to a SQL Express database, as this article[^] indicates. In the future, I suggest that you get your facts straight before engaging in a discussion.

                  Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                  Y 1 Reply Last reply
                  0
                  • P pmarfleet

                    yogesh_kumar_agarwal wrote:

                    i think you didn't read the connection string properly he tries to connect with a mdb database file means Access

                    No, you didn't read the connection string properly. The database file he was trying to connect to had a .mdf extension, not a .mdb extension. This is consistent with trying to connect to a SQL Express database, as this article[^] indicates. In the future, I suggest that you get your facts straight before engaging in a discussion.

                    Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                    Y Offline
                    Y Offline
                    yogesh_kumar_agarwal
                    wrote on last edited by
                    #11

                    Yes, i realize it, Sorry for discussion with regards Yogesh Agarwal

                    1 Reply Last reply
                    0
                    • L laziale

                      hi! I am building one web site, and I am a beginner in ASP.NET, I am attaching a database to the project and when I want to start the application I have this problem: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider Here is my connection string: SqlConnection con = new SqlConnection("Data Source=DILI/SQLEXPRESS;Initial Catalog=|App_Data|test2.mdf; user id=xxxx;password=xxxx;"); con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO test VALUES ('" + TextBox1.Text + "')"); cmd.ExecuteNonQuery(); Any Help?? Thanks Ahead

                      P Offline
                      P Offline
                      papadimitriou
                      wrote on last edited by
                      #12

                      i had the same problem .WHEN i had not started the SQL server when i was running the page . try to use the designer for the database connection . writing the code by yourself may caused errors.

                      f(yf) = yf

                      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