![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi: I've covered a number of newsgroups and web sites today, but still cannot seem to find out why my DTS package (which works fine via SQL) fails to work correctly when I execute it from a C# program. Here is the code I use: object pVarPersistStgOfHost = null; string val; try { //pkg.LoadFromSQLServer("(Local)", "sa","",0, "", "","", "authorsTest",ref pVarPersistStgOfHost); pkg.LoadFromSQLServer("(local)", "sa","",DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag _Default, "", "","", "authorsTest",ref pVarPersistStgOfHost); val=pkg.GlobalVariables.Item("city").Value.ToStrin g(); label1.Text=val; pkg.GlobalVariables.Remove("city"); DTS.GlobalVariable gv=pkg.GlobalVariables.New("city"); gv.Value="Oakland"; //pkg.GlobalVariables.Item("city").Value="Oakland"; pkg.GlobalVariables.Add(gv); label1.Text+=" *** "+pkg.GlobalVariables.Item("city").Value.ToString( ); pkg.Execute(); pkg.UnInitialize(); label1.Text+=" **** Success !!"; } catch (Exception ex) { label1.Text=ex.ToString(); } The label always displays the correct values too, but the spreadsheet (except for the column headers, is empty....no data returned) Thanks in advance for any help Ken |
#3
| |||
| |||
|
|
Have a look at these couple of articles/sites DTS Global Variables and Visual Basic .Net (http://www.sqldts.com/default.aspx?265) Converting a DTS Package from Visual Basic 6.0 to Visual Basic .Net (http://www.sqldts.com/default.aspx?264) http://www.sqldev.net/dts/DotNETCookBook.htm -- -- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "Keng" <nospam (AT) nospam (DOT) com> wrote in message news:ugU6$HVoDHA.2404 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hi: I've covered a number of newsgroups and web sites today, but still cannot seem to find out why my DTS package (which works fine via SQL) fails to work correctly when I execute it from a C# program. Here is the code I use: object pVarPersistStgOfHost = null; string val; try { //pkg.LoadFromSQLServer("(Local)", "sa","",0, "", "","", "authorsTest",ref pVarPersistStgOfHost); pkg.LoadFromSQLServer("(local)", "sa","",DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag _Default, "", "","", "authorsTest",ref pVarPersistStgOfHost); val=pkg.GlobalVariables.Item("city").Value.ToStrin g(); label1.Text=val; pkg.GlobalVariables.Remove("city"); DTS.GlobalVariable gv=pkg.GlobalVariables.New("city"); gv.Value="Oakland"; //pkg.GlobalVariables.Item("city").Value="Oakland"; pkg.GlobalVariables.Add(gv); label1.Text+=" *** "+pkg.GlobalVariables.Item("city").Value.ToString( ); pkg.Execute(); pkg.UnInitialize(); label1.Text+=" **** Success !!"; } catch (Exception ex) { label1.Text=ex.ToString(); } The label always displays the correct values too, but the spreadsheet (except for the column headers, is empty....no data returned) Thanks in advance for any help Ken |
#4
| |||
| |||
|
|
I've been to those sites.....tried the sample code......doesn't work on three different computers. Thanks for the reply.. "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote Have a look at these couple of articles/sites DTS Global Variables and Visual Basic .Net (http://www.sqldts.com/default.aspx?265) Converting a DTS Package from Visual Basic 6.0 to Visual Basic .Net (http://www.sqldts.com/default.aspx?264) http://www.sqldev.net/dts/DotNETCookBook.htm -- -- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "Keng" <nospam (AT) nospam (DOT) com> wrote in message news:ugU6$HVoDHA.2404 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hi: I've covered a number of newsgroups and web sites today, but still cannot seem to find out why my DTS package (which works fine via SQL) fails to work correctly when I execute it from a C# program. Here is the code I use: object pVarPersistStgOfHost = null; string val; try { //pkg.LoadFromSQLServer("(Local)", "sa","",0, "", "","", "authorsTest",ref pVarPersistStgOfHost); pkg.LoadFromSQLServer("(local)", "sa","",DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag _Default, "", "","", "authorsTest",ref pVarPersistStgOfHost); val=pkg.GlobalVariables.Item("city").Value.ToStrin g(); label1.Text=val; pkg.GlobalVariables.Remove("city"); DTS.GlobalVariable gv=pkg.GlobalVariables.New("city"); gv.Value="Oakland"; //pkg.GlobalVariables.Item("city").Value="Oakland"; pkg.GlobalVariables.Add(gv); label1.Text+=" *** "+pkg.GlobalVariables.Item("city").Value.ToString( ); pkg.Execute(); pkg.UnInitialize(); label1.Text+=" **** Success !!"; } catch (Exception ex) { label1.Text=ex.ToString(); } The label always displays the correct values too, but the spreadsheet (except for the column headers, is empty....no data returned) Thanks in advance for any help Ken |
#5
| |||
| |||
|
|
I've been to those sites.....tried the sample code......doesn't work on three different computers. Thanks for the reply.. |
#6
| |||
| |||
|
|
Hi: I've covered a number of newsgroups and web sites today, but still cannot seem to find out why my DTS package (which works fine via SQL) fails to work correctly when I execute it from a C# program. Here is the code I use: object pVarPersistStgOfHost = null; string val; try { //pkg.LoadFromSQLServer("(Local)", "sa","",0, "", "","", "authorsTest",ref pVarPersistStgOfHost); pkg.LoadFromSQLServer("(local)", "sa","",DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag _Default, "", "","", "authorsTest",ref pVarPersistStgOfHost); val=pkg.GlobalVariables.Item("city").Value.ToStrin g(); label1.Text=val; pkg.GlobalVariables.Remove("city"); DTS.GlobalVariable gv=pkg.GlobalVariables.New("city"); gv.Value="Oakland"; //pkg.GlobalVariables.Item("city").Value="Oakland"; pkg.GlobalVariables.Add(gv); label1.Text+=" *** "+pkg.GlobalVariables.Item("city").Value.ToString( ); pkg.Execute(); pkg.UnInitialize(); label1.Text+=" **** Success !!"; } catch (Exception ex) { label1.Text=ex.ToString(); } The label always displays the correct values too, but the spreadsheet (except for the column headers, is empty....no data returned) Thanks in advance for any help Ken |
![]() |
| Thread Tools | |
| Display Modes | |
| |