• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

can't connect to sql server in visual studio 2015

I'm migrating from a VBA/EXCEL app that connects to SQL Server and runs reports, to SSIS.  I use Visual Studio 2015, and connecting to Sql Server 2012.

I work at a large corporation that is pretty locked down.  I have been able to use an ADODB (2.8) connection using windows authentication.  

It is weird because the connection was working fine, and now it isn't.  I do need to move from windows authentication to SQL Server... I did that with the connection string (many variations attempted) but can't get it to work on my environment (VDI), but a co-worker can get it to work.

This is a lot of background, but I'm looking for a solution, because I can't do anything until I get a connection.

I'm wondering if I can use the data connection in Server Explorer, which does work fine.  I don't know if or how to make the connection in code to an ado object using the data connection in server explorer.  My attempt is in the last line of code below with DirectCast.

Below is my code, with all the attempts remmed out.  I was trying to open the connection, but then tried the direcast using sqlconnection instead.  I don't know if that will work, but I can't move forward because it says "dts" isn't declared.  

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports System.Configuration
Imports Microsoft.Office.Interop.Excel
Public Class frmRunReports

    Public Sub MainRunReports()
        Dim sConnString As String

        'Dim oConn As New ADODB.Connection
        Dim oConn As SqlClient.SqlConnection

        '******** OPEN DB CONNECTION
        'sConnString = "Provider = SQLOLEDB;Data Source=psin2p580.svr.us.jpmchase.net, 5544;Initial Catalog=Capsmis_Prod;Integrated Security=SSPI"
        'sConnString = "Server=psin2p580.svr.us.jpmchase.net,5544;Integrated Security=false;User Id=xxxxxx;Password=xxxxxxx;Database=CAPSMIS_Dev1"
        'sConnString = "Provider=SQLNCLI11;Server=psin2p580.svr.us.jpmchase.net,5544;Database=CAPSMIS_Dev1;Uid=xxxx;Pwd=xxxxxx;"
        'sConnString = "Persist Security Info=False;User ID=xxxxxxx;Password=xxxxxxx;Initial Catalog=CAPSMIS_Dev1;Server=psin2p580.svr.us.jpmchase.net,5544;"
        'sConnString = "Data Source='psin2p580.svr.us.jpmchase.net, 5544';Initial Catalog=CAPSMIS_DEV1;Persist Security Info=True;User ID=xxxx;Password=xxxxxx"
        'Data Source="psin2p580.svr.us.jpmchase.net, 5544";Initial Catalog=CAPSMIS_DEV1;Persist Security Info=True;User ID=xxxxxxx;Password=***********
        oConn = DirectCast(Dts.Connections("capsmis_prod").AcquireConnection(Dts.Transaction), SqlClient.SqlConnection)

Open in new window

  • 2
  • 2
1 Solution
Pushpakumara MahagamageVPCommented:
check following Article, there is so many connection types,


ADO.Net connection string is as follows

Server=yourserver,your-TCP-port;Initial Catalog=yourDB-Name;Persist Security Info=False;User ID=your_username;Password=your_password;Connection Timeout=30;
dougfosterNYCAuthor Commented:
I did see that webpage... and have tried all the combinations of connection strings, I think.

So there isn't a way to connect to the data connection in the Server Explorer?  That did connect successfully.

and I'm not sure why the DTS object isn't declared.  am I missing an import statement (at the top of the code in the original post)?
dougfosterNYCAuthor Commented:
Thanks, i forgot to close this question.
Pushpakumara MahagamageVPCommented:
You are welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now