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. General Programming
  3. Visual Basic
  4. Connection string for Integrated Security

Connection string for Integrated Security

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasesysadminsecurity
2 Posts 2 Posters 3 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.
  • U Offline
    U Offline
    User 13592306
    wrote on last edited by
    #1

    Hello:
    I am trying to connection using old school VBA.

    This works in VBA!
    connectionString = "Provider=sqloledb;Data Source=w2012;Initial Catalog=M1_SU;User Id=m1view;Password=connect2m1;"

    This works in VB.NET, but says the server does not exist or access is denied...
    "Provider=sqloledb;Data Source=sage;Initial Catalog=JobSheet;persist security info=True;Integrated Security=SSPI;"

    Why would the server be available in VB.NET but not in VBA?

    Here's the complete code. I must be missing something..
    Sub GetJobs_Click()
    Dim connectionString As String
    ' connectionString = "Provider=sqloledb;Data Source=w2012;Initial Catalog=M1_SU;User Id=m1view;Password=connect2m1;"
    connectionString = "Provider=sqloledb;Data Source=sage;Initial Catalog=JobSheet;persist security info=True;Integrated Security=SSPI;"
    Dim cn As ADODB.Connection
    Set cn = New ADODB.Connection

    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
        
    Dim sql As String
    sql = "SELECT \* From \[JobSheet\].\[dbo\].\[JobInfo\] ORDER BY JobNo "
    MsgBox (sql)
        
    cn.connectionString = connectionString
    \[COLOR="#FF0000"\]cn.Open ' ERROR'S HERE\[/COLOR\]
        
    rs.Open sql, cn, adOpenKeyset, adLockReadOnly, adCmdText
    rs.MoveFirst
    Do While Not rs.EOF
        MsgBox (rs.Fields("JobNo"))
        rs.MoveNext
    
    Loop
    
    rs.Close
    Set rs = Nothing
        
    cn.Close
    Set cn = Nothing
    

    End Sub

    Thanks!

    D 1 Reply Last reply
    0
    • U User 13592306

      Hello:
      I am trying to connection using old school VBA.

      This works in VBA!
      connectionString = "Provider=sqloledb;Data Source=w2012;Initial Catalog=M1_SU;User Id=m1view;Password=connect2m1;"

      This works in VB.NET, but says the server does not exist or access is denied...
      "Provider=sqloledb;Data Source=sage;Initial Catalog=JobSheet;persist security info=True;Integrated Security=SSPI;"

      Why would the server be available in VB.NET but not in VBA?

      Here's the complete code. I must be missing something..
      Sub GetJobs_Click()
      Dim connectionString As String
      ' connectionString = "Provider=sqloledb;Data Source=w2012;Initial Catalog=M1_SU;User Id=m1view;Password=connect2m1;"
      connectionString = "Provider=sqloledb;Data Source=sage;Initial Catalog=JobSheet;persist security info=True;Integrated Security=SSPI;"
      Dim cn As ADODB.Connection
      Set cn = New ADODB.Connection

      Dim rs As ADODB.Recordset
      Set rs = New ADODB.Recordset
          
      Dim sql As String
      sql = "SELECT \* From \[JobSheet\].\[dbo\].\[JobInfo\] ORDER BY JobNo "
      MsgBox (sql)
          
      cn.connectionString = connectionString
      \[COLOR="#FF0000"\]cn.Open ' ERROR'S HERE\[/COLOR\]
          
      rs.Open sql, cn, adOpenKeyset, adLockReadOnly, adCmdText
      rs.MoveFirst
      Do While Not rs.EOF
          MsgBox (rs.Fields("JobNo"))
          rs.MoveNext
      
      Loop
      
      rs.Close
      Set rs = Nothing
          
      cn.Close
      Set cn = Nothing
      

      End Sub

      Thanks!

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      "Integrated Security" just means to use the credentials of the account running your code. Unless the SQL Server is setup to accept the users Windows accounts as authentication, Integrated Security won't work.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      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