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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. open database

open database

Scheduled Pinned Locked Moved Database
databasecsharpcssvisual-studiodesign
5 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Once more we can't connect to the database. We get the age old message: Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed. Login failed for user 'HKRAM\Mark Hardenbergh'. HKRAM is the name of my computer. Mark Hardenbergh is, obviously, me. Which means to me there is something wrong with my user name. Anybody know what's wrong with my user name? Do I have another name? Where do I find my other name. I understand that I could use sa for my name, but that doesn't work either. Here is the code written on the default2.aspx.vb page, the code behind page. Imports System.Data.SqlClient Partial Class Default2 Inherits System.Web.UI.Page Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cn As New SqlConnection("C:\DOCUMENTS AND SETTINGS\MARK HARDENBERGH\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBSITE5\APP_DATA\VANILLA.MDF;user id=HKRAM\Mark Hardenbergh") Dim cmd As New SqlCommand With cmd .CommandType = Data.CommandType.StoredProcedure .CommandText = "mhhtrial" .Connection = cn .Connection.Open() .ExecuteNonQuery() .Connection.Close() .Dispose() End With End Sub No doubt everyone can recognize what I am trying to do. I am trying to perform the simple taks of running a stored procedure. It is in a database called vanilla.mdb. And, yes, it exist there. However I can't get to square 1 because the fool thing won't let me connect to vanilla.mdb. As you can imagine, I have a gridview that finds a table in vanilla.mdb and displays it beautifully. When I do gridviews and have the connection string turning up in web.config, there is no problem. The connection string that is in the web.config file is: <add name="VanillaConnectionString" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\Vanilla.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> It certainly would be nice, since this connection string obviously works, if I could use it in the vb in the code behind page. But, so far, no forum wants to explain that, much less any book I have bought. Can anyone straighten out this Dim cn as New SqlConnection....... out so I can move along?

    N A 2 Replies Last reply
    0
    • L Lost User

      Once more we can't connect to the database. We get the age old message: Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed. Login failed for user 'HKRAM\Mark Hardenbergh'. HKRAM is the name of my computer. Mark Hardenbergh is, obviously, me. Which means to me there is something wrong with my user name. Anybody know what's wrong with my user name? Do I have another name? Where do I find my other name. I understand that I could use sa for my name, but that doesn't work either. Here is the code written on the default2.aspx.vb page, the code behind page. Imports System.Data.SqlClient Partial Class Default2 Inherits System.Web.UI.Page Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cn As New SqlConnection("C:\DOCUMENTS AND SETTINGS\MARK HARDENBERGH\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBSITE5\APP_DATA\VANILLA.MDF;user id=HKRAM\Mark Hardenbergh") Dim cmd As New SqlCommand With cmd .CommandType = Data.CommandType.StoredProcedure .CommandText = "mhhtrial" .Connection = cn .Connection.Open() .ExecuteNonQuery() .Connection.Close() .Dispose() End With End Sub No doubt everyone can recognize what I am trying to do. I am trying to perform the simple taks of running a stored procedure. It is in a database called vanilla.mdb. And, yes, it exist there. However I can't get to square 1 because the fool thing won't let me connect to vanilla.mdb. As you can imagine, I have a gridview that finds a table in vanilla.mdb and displays it beautifully. When I do gridviews and have the connection string turning up in web.config, there is no problem. The connection string that is in the web.config file is: <add name="VanillaConnectionString" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\Vanilla.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> It certainly would be nice, since this connection string obviously works, if I could use it in the vb in the code behind page. But, so far, no forum wants to explain that, much less any book I have bought. Can anyone straighten out this Dim cn as New SqlConnection....... out so I can move along?

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Your user name is the smae as the account name with which you login to your machine with, not necessary your full name. Also, when posting code here make sure to format it by using pre tags.


      I know the language. I've read a book. - _Madmatt

      L 1 Reply Last reply
      0
      • L Lost User

        Once more we can't connect to the database. We get the age old message: Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed. Login failed for user 'HKRAM\Mark Hardenbergh'. HKRAM is the name of my computer. Mark Hardenbergh is, obviously, me. Which means to me there is something wrong with my user name. Anybody know what's wrong with my user name? Do I have another name? Where do I find my other name. I understand that I could use sa for my name, but that doesn't work either. Here is the code written on the default2.aspx.vb page, the code behind page. Imports System.Data.SqlClient Partial Class Default2 Inherits System.Web.UI.Page Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cn As New SqlConnection("C:\DOCUMENTS AND SETTINGS\MARK HARDENBERGH\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBSITE5\APP_DATA\VANILLA.MDF;user id=HKRAM\Mark Hardenbergh") Dim cmd As New SqlCommand With cmd .CommandType = Data.CommandType.StoredProcedure .CommandText = "mhhtrial" .Connection = cn .Connection.Open() .ExecuteNonQuery() .Connection.Close() .Dispose() End With End Sub No doubt everyone can recognize what I am trying to do. I am trying to perform the simple taks of running a stored procedure. It is in a database called vanilla.mdb. And, yes, it exist there. However I can't get to square 1 because the fool thing won't let me connect to vanilla.mdb. As you can imagine, I have a gridview that finds a table in vanilla.mdb and displays it beautifully. When I do gridviews and have the connection string turning up in web.config, there is no problem. The connection string that is in the web.config file is: <add name="VanillaConnectionString" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\Vanilla.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> It certainly would be nice, since this connection string obviously works, if I could use it in the vb in the code behind page. But, so far, no forum wants to explain that, much less any book I have bought. Can anyone straighten out this Dim cn as New SqlConnection....... out so I can move along?

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #3

        mhh112 wrote:

        Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.

        The error really tells you the problem - Cannot open user default database which means your user is not set up correctly in SQL Server. Go in and see what your default database is set to, or change your connection string to specify the database you want to use.

        Bob Ashfield Consultants Ltd

        1 Reply Last reply
        0
        • N Not Active

          Your user name is the smae as the account name with which you login to your machine with, not necessary your full name. Also, when posting code here make sure to format it by using pre tags.


          I know the language. I've read a book. - _Madmatt

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          What, pray tell, are pre tags? Do I use them on every line of code or just at the start and at the end of code?

          N 1 Reply Last reply
          0
          • L Lost User

            What, pray tell, are pre tags? Do I use them on every line of code or just at the start and at the end of code?

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            How to get an answer to your question[^]


            I know the language. I've read a book. - _Madmatt

            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