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. Unable to connect to PUBS database

Unable to connect to PUBS database

Scheduled Pinned Locked Moved ASP.NET
questiondatabasesecurityhelpworkspace
3 Posts 2 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.
  • K Offline
    K Offline
    KaKa
    wrote on last edited by
    #1

    Whenever I try to connect to the PUBS.MDF database, a login failed error message will appear. I defined the connection string in the web.config file under the connectionstrings section like this: [code] add name="Pubs" connectionString="Data Source = localhost\SQLEXPRESS; Initial Catalog=Pubs;Integrated Security=SSPI" [/code] And setup the connection in the click event of a button: [code] Dim connectionString As String = WebConfigurationManager.ConnectionStrings("Pubs").ConnectionString Dim myConnection As New SqlConnection(connectionString) myConnection.Open() .......... [/code] And I put the PUBS.MDF file in the same folder as the vb source files. How do I connect to the database correctly?

    C 1 Reply Last reply
    0
    • K KaKa

      Whenever I try to connect to the PUBS.MDF database, a login failed error message will appear. I defined the connection string in the web.config file under the connectionstrings section like this: [code] add name="Pubs" connectionString="Data Source = localhost\SQLEXPRESS; Initial Catalog=Pubs;Integrated Security=SSPI" [/code] And setup the connection in the click event of a button: [code] Dim connectionString As String = WebConfigurationManager.ConnectionStrings("Pubs").ConnectionString Dim myConnection As New SqlConnection(connectionString) myConnection.Open() .......... [/code] And I put the PUBS.MDF file in the same folder as the vb source files. How do I connect to the database correctly?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      KaKa` wrote:

      add name="Pubs" connectionString="Data Source = localhost\SQLEXPRESS; Initial Catalog=Pubs;Integrated Security=SSPI"

      This looks for a named instance of SQL Server called SQLEXPRESS, and then tries to find a DB called pubs in there. It sure as hell isn't going to find a file called 'pubs.mdf' ( which is an access database )

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      K 1 Reply Last reply
      0
      • C Christian Graus

        KaKa` wrote:

        add name="Pubs" connectionString="Data Source = localhost\SQLEXPRESS; Initial Catalog=Pubs;Integrated Security=SSPI"

        This looks for a named instance of SQL Server called SQLEXPRESS, and then tries to find a DB called pubs in there. It sure as hell isn't going to find a file called 'pubs.mdf' ( which is an access database )

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        K Offline
        K Offline
        KaKa
        wrote on last edited by
        #3

        what is the database extension supposed to be? I downloaded it from the microsoft website and it states that these databases are for sql server 2000.

        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