![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I am getting an error "[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied." when I try and execute a DTS package from VB.NET (forms) using the method LoadFromSQLServer. I am trying to execute a package from a remote SQL Server. The package has one connection in it and I use the Server name not (Local) and use SQL Server authentication ( the user has priviliges on the database). I can execute the package through Enterprise Manager successfully if i log into the machine. I created the package under my windows account ( which is a domain admin) I want this windows app to be used by other people so the parameters I used for the method LoadFromSQLServer were "server name" , "username", "password", DTSSQLStgFlag_UseTrustedConnection flag and "package name". Should I be using my account details for username and password? I can execute the package if i log into the SQL Server (under my account) Any help will be appreciated Cheers Damian |
#3
| |||
| |||
|
|
Hi Damian, The reason you are having trouble is that, from .NET's point of view, you're trying to call COM DLLs from .NET code. You need to wrap your COM DLL in something .NET can talk to: Therefore you need to do four things: 1) Create a strong name key pair file using sn.exe. This enables you to create an assembly that is uniquely identifiable. Switch to the folder c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin and execute: e.g. sn.exe –k C:\MyDTSKey.KEY 2) Use TlbImp.exe (Type Library Import) to import the main DTS DLL file into a runtime callable wrapper (RCW) DLL to enable COM to interact with .NET. e.g. Tlbimp.exe "c:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtspkg.dll" /out:c:\Microsoft.SqlServer.DTSPkgDotNet.dll /keyfile:C:\MyDTSKey.KEY 3) Register the RCW in the GAC (Global Assembly Cache): Gacutil.exe –I c:\Microsoft.SqlServer.DTSPkgDotNet.dll 4) Reference this file in your .NET code. You're good to go! Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email alias: charles email domain: kangai.demon.co.uk "damian_meleo (AT) hotmail (DOT) com" wrote: Hi, I am getting an error "[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied." when I try and execute a DTS package from VB.NET (forms) using the method LoadFromSQLServer. I am trying to execute a package from a remote SQL Server. The package has one connection in it and I use the Server name not (Local) and use SQL Server authentication ( the user has priviliges on the database). I can execute the package through Enterprise Manager successfully if i log into the machine. I created the package under my windows account ( which is a domain admin) I want this windows app to be used by other people so the parameters I used for the method LoadFromSQLServer were "server name" , "username", "password", DTSSQLStgFlag_UseTrustedConnection flag and "package name". Should I be using my account details for username and password? I can execute the package if i log into the SQL Server (under my account) Any help will be appreciated Cheers Damian |
#4
| |||
| |||
|
|
Here is sample code to run from VB.NET: Imports Microsoft.SQLServer.DTSDotNetPkg Module MyPackage Sub Main() Dim package As New DTS.Package2Class Dim filename As String = "C:\Packages\SomePackage.dts" Dim pwd As String = "" Dim packageGUID As String = "" Dim versionGUID As String = "" Dim name As String = "MyPackage" 'package.LoadFromSQLServer("(local)", "sa", "sapw", , , , , name, "") package.LoadFromStorageFile(filename, "", , , name, ) package.Execute() package.UnInitialize() package = Nothing End Sub Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email alias: charles email domain: kangai.demon.co.uk "Charles Kangai" wrote: Hi Damian, The reason you are having trouble is that, from .NET's point of view, you're trying to call COM DLLs from .NET code. You need to wrap your COM DLL in something .NET can talk to: Therefore you need to do four things: 1) Create a strong name key pair file using sn.exe. This enables you to create an assembly that is uniquely identifiable. Switch to the folder c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin and execute: e.g. sn.exe -k C:\MyDTSKey.KEY 2) Use TlbImp.exe (Type Library Import) to import the main DTS DLL file into a runtime callable wrapper (RCW) DLL to enable COM to interact with .NET. e.g. Tlbimp.exe "c:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtspkg.dll" /out:c:\Microsoft.SqlServer.DTSPkgDotNet.dll /keyfile:C:\MyDTSKey.KEY 3) Register the RCW in the GAC (Global Assembly Cache): Gacutil.exe -I c:\Microsoft.SqlServer.DTSPkgDotNet.dll 4) Reference this file in your .NET code. You're good to go! Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email alias: charles email domain: kangai.demon.co.uk "damian_meleo (AT) hotmail (DOT) com" wrote: Hi, I am getting an error "[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied." when I try and execute a DTS package from VB.NET (forms) using the method LoadFromSQLServer. I am trying to execute a package from a remote SQL Server. The package has one connection in it and I use the Server name not (Local) and use SQL Server authentication ( the user has priviliges on the database). I can execute the package through Enterprise Manager successfully if i log into the machine. I created the package under my windows account ( which is a domain admin) I want this windows app to be used by other people so the parameters I used for the method LoadFromSQLServer were "server name" , "username", "password", DTSSQLStgFlag_UseTrustedConnection flag and "package name". Should I be using my account details for username and password? I can execute the package if i log into the SQL Server (under my account) Any help will be appreciated Cheers Damian |
![]() |
| Thread Tools | |
| Display Modes | |
| |