dbTalk Databases Forums  

Global Variable Already Exists in the Collection

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Global Variable Already Exists in the Collection in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jelling@global-image.com
 
Posts: n/a

Default Global Variable Already Exists in the Collection - 01-12-2005 , 06:13 PM






Hello,
I'm getting the following error when executing a DTS package from
VB.Net. The DTS packages runs fine from the designer and used to run
fine as well from VB.net

"Global variable 'ExportedRowCount' already exists in the collection"

Here's my vb.net code. The error occurs right after the
..LoadFromSqlServer

SELECT @@VERSION = "Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation
Developer Edition on Windows NT 5.2 (Build 3790: "

Note: I tried specifying the GUID for the package and vesion also, but
this didn't help.

Please help as I'm pulling out my hair.
Thanks,
..jelling


Dim dbServer As String = AppSettings("dbServer")
Dim uid As String = AppSettings("uid")
Dim pwd As String = AppSettings("pwd")
Dim packageName As String = AppSettings("PE_DTSPackageName")
Dim checkRecordsError As String
Dim exportedRowCount As Integer
Dim exportedFileName As String = m_sWorkingDir & "\" &
GetTodaysFileName()
Dim i As Integer
Dim ExStatus As String


Dim objDTS As New DTS.Package()

Try
With objDTS

..LoadFromSQLServer(dbServer, uid, pwd,
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default , , , , packageName)
..GlobalVariables.Remove("StartDate")
..GlobalVariables.AddGlobalVariable("StartDate",
m_dStartDate)
..GlobalVariables.Remove("EndDate")
..GlobalVariables.AddGlobalVariable("EndDate",
m_dEndDate)
..GlobalVariables.Remove("SubStatusCodesToExport")

..GlobalVariables.AddGlobalVariable("SubStatusCode sToExport",
m_sStatusFilter)
..GlobalVariables.Remove("Company")
..GlobalVariables.AddGlobalVariable("Company",
m_sVendor)
..GlobalVariables.Remove("OutboundFile")
..GlobalVariables.AddGlobalVariable("OutboundFile" ,
m_sFtpDestDir & "\archive\" & m_sTodaysFileName)
'# i tried these next two lines with no luck after the
problem started
'.GlobalVariables.Remove("ExportedRowCount")
'.GlobalVariables.AddGlobalVariable("ExportedRowCo unt",
0)
.Execute()
End With


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Global Variable Already Exists in the Collection - 01-13-2005 , 12:44 AM






I have had this previously as well and never did discover what it was. I
also seem to remember a problem with SQLDMO and EM doing this as well.
Have you made absolutely sure you are deleting the GV?
Have you tried saving off the package to another location by itself and
loading?

--



Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
www.konesans.com - Consultancy from the people who know


<jelling (AT) global-image (DOT) com> wrote

Quote:
Hello,
I'm getting the following error when executing a DTS package from
VB.Net. The DTS packages runs fine from the designer and used to run
fine as well from VB.net

"Global variable 'ExportedRowCount' already exists in the collection"

Here's my vb.net code. The error occurs right after the
.LoadFromSqlServer

SELECT @@VERSION = "Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation
Developer Edition on Windows NT 5.2 (Build 3790: "

Note: I tried specifying the GUID for the package and vesion also, but
this didn't help.

Please help as I'm pulling out my hair.
Thanks,
.jelling


Dim dbServer As String = AppSettings("dbServer")
Dim uid As String = AppSettings("uid")
Dim pwd As String = AppSettings("pwd")
Dim packageName As String = AppSettings("PE_DTSPackageName")
Dim checkRecordsError As String
Dim exportedRowCount As Integer
Dim exportedFileName As String = m_sWorkingDir & "\" &
GetTodaysFileName()
Dim i As Integer
Dim ExStatus As String


Dim objDTS As New DTS.Package()

Try
With objDTS

.LoadFromSQLServer(dbServer, uid, pwd,
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default , , , , packageName)
.GlobalVariables.Remove("StartDate")
.GlobalVariables.AddGlobalVariable("StartDate",
m_dStartDate)
.GlobalVariables.Remove("EndDate")
.GlobalVariables.AddGlobalVariable("EndDate",
m_dEndDate)
.GlobalVariables.Remove("SubStatusCodesToExport")

.GlobalVariables.AddGlobalVariable("SubStatusCodes ToExport",
m_sStatusFilter)
.GlobalVariables.Remove("Company")
.GlobalVariables.AddGlobalVariable("Company",
m_sVendor)
.GlobalVariables.Remove("OutboundFile")
.GlobalVariables.AddGlobalVariable("OutboundFile",
m_sFtpDestDir & "\archive\" & m_sTodaysFileName)
'# i tried these next two lines with no luck after the
problem started
'.GlobalVariables.Remove("ExportedRowCount")
'.GlobalVariables.AddGlobalVariable("ExportedRowCo unt",
0)
.Execute()
End With




Reply With Quote
  #3  
Old   
jelling@global-image.com
 
Posts: n/a

Default Re: Global Variable Already Exists in the Collection - 01-13-2005 , 02:31 PM



Thanks for the reply Allan. Yeah, I was certain that I had deleted the
GV in the code and I had also tried removing it in the DTS job,
although that limited the functionality of my package.

Anywhow, I solved the issue by renaming the variable. I just added a
"2" to the previous variable name and all was fine. Strange.
Thanks again,
Jon Elling


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.