Link to home
Start Free TrialLog in
Avatar of Doug Foster
Doug FosterFlag for United States of America

asked on

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=***********
        'MsgBox(sConnString)
        'oConn.Open(sConnString)
        oConn = DirectCast(Dts.Connections("capsmis_prod").AcquireConnection(Dts.Transaction), SqlClient.SqlConnection)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pushpakumara Mahagamage
Pushpakumara Mahagamage
Flag of Sri Lanka image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Doug Foster

ASKER

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)?
Thanks, i forgot to close this question.
You are welcome.