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. connecting to SQL express through ADO

connecting to SQL express through ADO

Scheduled Pinned Locked Moved Database
databasesql-serversysadminsecurityquestion
10 Posts 4 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.
  • P Offline
    P Offline
    psasidisrcum
    wrote on last edited by
    #1

    Hi all, I have SQL server express edition 2005 installed on my computer and using VB in MS Access to run some queries. The VB function looks something like this.. Dim dataRS As New ADODB.Recordset Dim cnnSQL As New ADODB.Connection Set cnnSQL = New ADODB.Connection cnnSQL.ConnectionString = "Provider=SQLNCLI;Server=.\SQLExpress;Database=TestDB;Trusted_Connection=yes;" cnnSQL.Properties("Integrated Security").Value = "SSPI" cnnSQL.Open dataRS.Open "SELECT dbo_Table_1.* FROM dbo_Table_1", cnnSQL, adOpenStatic, adLockOptimistic The code fails though, on the last line with message "Invalid object name 'dbo_Table_1'" (yes, I verified that the table actually does exist in the DB) I must be doing something wrong with the connection string but all the things that I've tried so far haven't worked.. Can anyone offer any suggestions? Thanks in advance,

    J S C 3 Replies Last reply
    0
    • P psasidisrcum

      Hi all, I have SQL server express edition 2005 installed on my computer and using VB in MS Access to run some queries. The VB function looks something like this.. Dim dataRS As New ADODB.Recordset Dim cnnSQL As New ADODB.Connection Set cnnSQL = New ADODB.Connection cnnSQL.ConnectionString = "Provider=SQLNCLI;Server=.\SQLExpress;Database=TestDB;Trusted_Connection=yes;" cnnSQL.Properties("Integrated Security").Value = "SSPI" cnnSQL.Open dataRS.Open "SELECT dbo_Table_1.* FROM dbo_Table_1", cnnSQL, adOpenStatic, adLockOptimistic The code fails though, on the last line with message "Invalid object name 'dbo_Table_1'" (yes, I verified that the table actually does exist in the DB) I must be doing something wrong with the connection string but all the things that I've tried so far haven't worked.. Can anyone offer any suggestions? Thanks in advance,

      J Offline
      J Offline
      Jerry Hammond
      wrote on last edited by
      #2

      psasidisrcum wrote:

      "SELECT dbo_Table_1.* FROM dbo_Table_1

      I'm not exactly sure, but isn't it odd to SELECT Table1 FROM Table1? You also have a period after the first dbp_Table_1 which may be causing fits. Jerry

      "When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus

      C 1 Reply Last reply
      0
      • P psasidisrcum

        Hi all, I have SQL server express edition 2005 installed on my computer and using VB in MS Access to run some queries. The VB function looks something like this.. Dim dataRS As New ADODB.Recordset Dim cnnSQL As New ADODB.Connection Set cnnSQL = New ADODB.Connection cnnSQL.ConnectionString = "Provider=SQLNCLI;Server=.\SQLExpress;Database=TestDB;Trusted_Connection=yes;" cnnSQL.Properties("Integrated Security").Value = "SSPI" cnnSQL.Open dataRS.Open "SELECT dbo_Table_1.* FROM dbo_Table_1", cnnSQL, adOpenStatic, adLockOptimistic The code fails though, on the last line with message "Invalid object name 'dbo_Table_1'" (yes, I verified that the table actually does exist in the DB) I must be doing something wrong with the connection string but all the things that I've tried so far haven't worked.. Can anyone offer any suggestions? Thanks in advance,

        S Offline
        S Offline
        S Douglas
        wrote on last edited by
        #3

        psasidisrcum wrote:

        Dim cnnSQL As New ADODB.Connection Set cnnSQL = New ADODB.Connection

        Are you sure the root cause isn’t the double initialize of cnnSQL? Dim cnnSQL As ADODB.Connection Set cnnSQL = New ADODB.Connection

        psasidisrcum wrote:

        dataRS.Open "SELECT * FROM dbo_Table_1", cnnSQL, adOpenStatic, adLockOptimistic


        I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

        C 1 Reply Last reply
        0
        • J Jerry Hammond

          psasidisrcum wrote:

          "SELECT dbo_Table_1.* FROM dbo_Table_1

          I'm not exactly sure, but isn't it odd to SELECT Table1 FROM Table1? You also have a period after the first dbp_Table_1 which may be causing fits. Jerry

          "When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus

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

          Jerry Hammond wrote:

          I'm not exactly sure, but isn't it odd to SELECT Table1 FROM Table1?

          He isn't he's selecting dbo_Table1.* which is a valid notation to mean all columns from dbo_Table1 - It is most commonly used when there are joined tables - It is redundant if there is only one table in the select because SELECT * would be just as effective.

          Jerry Hammond wrote:

          You also have a period after the first dbp_Table_1 which may be causing fits.

          The dot is to allow you to more fully qualify a name if there is some ambiguity. Here the notation is reduntant because there is no ambiguity. The full notation is: [server].[database].[owner].[table].[column]


          Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

          J 1 Reply Last reply
          0
          • P psasidisrcum

            Hi all, I have SQL server express edition 2005 installed on my computer and using VB in MS Access to run some queries. The VB function looks something like this.. Dim dataRS As New ADODB.Recordset Dim cnnSQL As New ADODB.Connection Set cnnSQL = New ADODB.Connection cnnSQL.ConnectionString = "Provider=SQLNCLI;Server=.\SQLExpress;Database=TestDB;Trusted_Connection=yes;" cnnSQL.Properties("Integrated Security").Value = "SSPI" cnnSQL.Open dataRS.Open "SELECT dbo_Table_1.* FROM dbo_Table_1", cnnSQL, adOpenStatic, adLockOptimistic The code fails though, on the last line with message "Invalid object name 'dbo_Table_1'" (yes, I verified that the table actually does exist in the DB) I must be doing something wrong with the connection string but all the things that I've tried so far haven't worked.. Can anyone offer any suggestions? Thanks in advance,

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

            psasidisrcum wrote:

            The code fails though, on the last line with message "Invalid object name 'dbo_Table_1'"

            Are you sure you really have a table name called dbo_Table_1? Are you sure it isn't dbo.Table_1? (i.e. there is a dot between dbo and Table_1 rather than an underscore)


            Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

            1 Reply Last reply
            0
            • S S Douglas

              psasidisrcum wrote:

              Dim cnnSQL As New ADODB.Connection Set cnnSQL = New ADODB.Connection

              Are you sure the root cause isn’t the double initialize of cnnSQL? Dim cnnSQL As ADODB.Connection Set cnnSQL = New ADODB.Connection

              psasidisrcum wrote:

              dataRS.Open "SELECT * FROM dbo_Table_1", cnnSQL, adOpenStatic, adLockOptimistic


              I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

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

              S Douglas wrote:

              Are you sure the root cause isn’t the double initialize of cnnSQL?

              While the double initialisation is redundant it is unlikely to be the cause of the problem because the second connection is constructed over the first before anything is done with the first connection.


              Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

              S 1 Reply Last reply
              0
              • C Colin Angus Mackay

                Jerry Hammond wrote:

                I'm not exactly sure, but isn't it odd to SELECT Table1 FROM Table1?

                He isn't he's selecting dbo_Table1.* which is a valid notation to mean all columns from dbo_Table1 - It is most commonly used when there are joined tables - It is redundant if there is only one table in the select because SELECT * would be just as effective.

                Jerry Hammond wrote:

                You also have a period after the first dbp_Table_1 which may be causing fits.

                The dot is to allow you to more fully qualify a name if there is some ambiguity. Here the notation is reduntant because there is no ambiguity. The full notation is: [server].[database].[owner].[table].[column]


                Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

                J Offline
                J Offline
                Jerry Hammond
                wrote on last edited by
                #7

                Colin Angus Mackay wrote:

                He isn't he's selecting dbo_Table1.* which is a valid notation to mean all columns from dbo_Table1 - It is most commonly used when there are joined tables - It is redundant if there is only one table in the select because SELECT * would be just as effective.

                Cool. That is good to know. He does say, "yes, I verified that the table actually does exist in the DB)".

                Colin Angus Mackay wrote:

                The dot is to allow you to more fully qualify a name if there is some ambiguity. Here the notation is reduntant because there is no ambiguity. The full notation is: [server].[database].[owner].[table].[column]

                Right. That would mean--I assume--that when he writes dbo_Table_1. he is selecting his Server?

                "When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus

                C 1 Reply Last reply
                0
                • J Jerry Hammond

                  Colin Angus Mackay wrote:

                  He isn't he's selecting dbo_Table1.* which is a valid notation to mean all columns from dbo_Table1 - It is most commonly used when there are joined tables - It is redundant if there is only one table in the select because SELECT * would be just as effective.

                  Cool. That is good to know. He does say, "yes, I verified that the table actually does exist in the DB)".

                  Colin Angus Mackay wrote:

                  The dot is to allow you to more fully qualify a name if there is some ambiguity. Here the notation is reduntant because there is no ambiguity. The full notation is: [server].[database].[owner].[table].[column]

                  Right. That would mean--I assume--that when he writes dbo_Table_1. he is selecting his Server?

                  "When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus

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

                  Jerry Hammond wrote:

                  Right. That would mean--I assume--that when he writes dbo_Table_1. he is selecting his Server?

                  No, it goes the other way around. The column is the mandatory bit, so it will parse as if the colum is the last thing and work back from there. Valid sequences, when expecting a column name, are therefore: [server].[database].[owner].[table].[column] [database].[owner].[table].[column] [owner].[table].[column] [table].[column] [column] Valid sequences, when expecting a table name, are: [server].[database].[owner].[table] [database].[owner].[table] [owner].[table] [table] (Note the owner name, in both cases, can be omitted when it is the dbo, so you'd get the two dots with nothing inbetween. e.g. mydatabase..mytable)


                  Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

                  J 1 Reply Last reply
                  0
                  • C Colin Angus Mackay

                    Jerry Hammond wrote:

                    Right. That would mean--I assume--that when he writes dbo_Table_1. he is selecting his Server?

                    No, it goes the other way around. The column is the mandatory bit, so it will parse as if the colum is the last thing and work back from there. Valid sequences, when expecting a column name, are therefore: [server].[database].[owner].[table].[column] [database].[owner].[table].[column] [owner].[table].[column] [table].[column] [column] Valid sequences, when expecting a table name, are: [server].[database].[owner].[table] [database].[owner].[table] [owner].[table] [table] (Note the owner name, in both cases, can be omitted when it is the dbo, so you'd get the two dots with nothing inbetween. e.g. mydatabase..mytable)


                    Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

                    J Offline
                    J Offline
                    Jerry Hammond
                    wrote on last edited by
                    #9

                    Cool beans, Colin. Thanks for clearing that up for me.

                    "When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus

                    1 Reply Last reply
                    0
                    • C Colin Angus Mackay

                      S Douglas wrote:

                      Are you sure the root cause isn’t the double initialize of cnnSQL?

                      While the double initialisation is redundant it is unlikely to be the cause of the problem because the second connection is constructed over the first before anything is done with the first connection.


                      Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

                      S Offline
                      S Offline
                      S Douglas
                      wrote on last edited by
                      #10

                      Colin Angus Mackay wrote:

                      it is unlikely to be the cause of the problem because the second connection is constructed over the first before anything is done with the first connection.

                      CP choked on my post and I was way to lazy (well tired) to retype it all out again. I have had issues with simple errors of that nature. Nothing big just flaky behavior by the object.


                      I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

                      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