Monday, March 26, 2012

executing dts package through asp.net creates tables but no data!

hey out there,

just started playing with this so bare with me...

i've used the data export wizard to create a dts package in sql server 2000. the package takes selected tables, creates an access database and then dumps all the data into the tables.

it works fine when i run the package in enterprise manager, but when i call it from asp.net (vb.net) the access database gets created, the tables are created but it fails to dump the data!

this is my code:

1Public Sub executeDts()23Dim oPkgAs DTS.Package24 oPkg =New DTS.Package25Dim oStepAs DTS.Step6 Dim sMessageAs New StringBuilder789 oPkg.LoadFromSQLServer("serverNameHere","userNameHere","passwordHere", DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, , , ,"packageNameHere")1011For Each oStepIn oPkg.Steps1213 sMessage.Append("<p> Step [" & oStep.Name &"] ")1415If oStep.ExecutionResult = DTSStepExecResult.DTSStepExecResult_FailureThen1617 sMessage.Append(" failed<br>")1819Else2021 sMessage.Append(" succeeded<br>")2223End If2425 sMessage.Append("Task """ & oPkg.Tasks.Item(oStep.TaskName).Description &"""</p>")2627Next2829 Response.Write("sMessage = " & sMessage.ToString &"<br/>")3031 oPkg.Execute()3233 oPkg.UnInitialize()3435 oPkg =Nothing3637 End Sub38

am i missing a step?! it seems very odd that the tables are created but the insert fails...

any advice anyone can offer would be great!

cheers,

jake

hi jake the code is perfect but there is one tiny little error

just put the DTS.Execute() statement before theFor loop block

this should solve your problem

take care brother

happy coding

|||

hi jake

the code is perfect but there is one tiny little error

just put the DTS.Execute() statement before theFor loop block

this should solve your problem

take care brother

happy coding

sql

No comments:

Post a Comment