Showing posts with label excute. Show all posts
Showing posts with label excute. Show all posts

Wednesday, March 21, 2012

Need some help with DTexec execution

Hi!

When i excute in the sql server this works fine

xp_cmdshell 'dtexec /f "D:\SSISProject\Integration Services Project1\ArchiveTicket.dtsx "'

but when i excute throught the C# code

jobCommand = new SqlCommand(@."xp_cmdshell 'dtexec /f "D:\SSISProject\Integration Services Project1\ArchiveTicket.dtsx"'", cconn);

It shows up red lines near the " and ' qoutes. I know that quotation marks are wrong but don't know how to solve it.

some help please

Thanks

jas

When C# compiler encounters the second quote symbol (right after /f) it thinks this is the end of the string. To indicate this is embedded quote inside the string, double it, otherwise C# has no way to determine your intentions:

jobCommand = new SqlCommand(@."xp_cmdshell 'dtexec /f ""D:\SSISProject\Integration Services Project1\ArchiveTicket.dtsx""' ", cconn);

|||

Thanks a Lot It worked

Jas

|||

one more guidance needed with regard to the Quotation marks

path = @."D:\SSISProject\Integration Services Project1\ArchiveTicket.dtsx";

jobCommand = new SqlCommand(@."xp_cmdshell 'dtexec /f "'path '" /Set \package.Variables[User::ArchiveFileType].Properties[Value];""Excel""'", cconn);

How Do i set the path's value in c# the quotation marks are wrong again. cos i want to set value of path according to selection in the UI.

Select("deviceUniqueId = '" + deviceUniqueId + "'"); is an e.g of Doing in C# but when i implement it through text it does not recognize

Thanks

Jas

Need some help about DTS

I have create a DTS package, This job is fist connect to database, and
then excute a SQL query, then use the VB ActiveX to create a procedure
to store the sql result to a text file. I ran the package there is no
porblem with query.But the second step for output the result to text
file have problem. The test fiel become 200mb big and cannot open. I
would like to know if there something wrong with my programming.
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
On Error Resume Next
Dim strRecord
Dim strEmailBody
Dim objFSO
Dim objStream
Dim objResults
Const OUTPUT_FILE = "c:\CompanyList.txt"
Const fsoForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objResults = DTSGlobalVariables("gResults").Value
Set objStream = objFSO.OpenTextFile(OUTPUT_FILE, fsoForWriting, True)
'Loop through the records and output each one
'to a file.
While Not objResults.EOF
strRecord = "Relatiecode #" & objResults.Fields(0).Value & _
"JA/NEE" & objResults.Fields(1).Value
objStream.WriteLine (strRecord)
objStream.WriteBlankLines (1)
objResults.MoveNext
Wend
If Err.Count = 0 Then
Main = DTSTaskExecResult_Success
Else
Main = DTSTaskExecResult_Failure
End If
End FunctionHi
"superbaby@.gmail.com" wrote:
> I have create a DTS package, This job is fist connect to database, and
> then excute a SQL query, then use the VB ActiveX to create a procedure
> to store the sql result to a text file. I ran the package there is no
> porblem with query.But the second step for output the result to text
> file have problem. The test fiel become 200mb big and cannot open. I
> would like to know if there something wrong with my programming.
> '**********************************************************************
> ' Visual Basic ActiveX Script
> '************************************************************************
> Function Main()
> On Error Resume Next
> Dim strRecord
> Dim strEmailBody
> Dim objFSO
> Dim objStream
> Dim objResults
> Const OUTPUT_FILE = "c:\CompanyList.txt"
> Const fsoForWriting = 2
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objResults = DTSGlobalVariables("gResults").Value
> Set objStream = objFSO.OpenTextFile(OUTPUT_FILE, fsoForWriting, True)
> 'Loop through the records and output each one
> 'to a file.
> While Not objResults.EOF
> strRecord = "Relatiecode #" & objResults.Fields(0).Value & _
> "JA/NEE" & objResults.Fields(1).Value
> objStream.WriteLine (strRecord)
> objStream.WriteBlankLines (1)
> objResults.MoveNext
> Wend
>
> If Err.Count = 0 Then
> Main = DTSTaskExecResult_Success
> Else
> Main = DTSTaskExecResult_Failure
> End If
> End Function
>
You don't seem to be closing the file and setting your cleaning up the
objects by setting them to nothing for examples see
http://www.sqldts.com/303.aspx
I am not sure if it will not solve the problem though!!
John

Need some help about DTS

I have create a DTS package, This job is fist connect to database, and
then excute a SQL query, then use the VB ActiveX to create a procedure
to store the sql result to a text file. I ran the package there is no
porblem with query.But the second step for output the result to text
file have problem. The test fiel become 200mb big and cannot open. I
would like to know if there something wrong with my programming.
'***************************************
*******************************
' Visual Basic ActiveX Script
'***************************************
*********************************
Function Main()
On Error Resume Next
Dim strRecord
Dim strEmailBody
Dim objFSO
Dim objStream
Dim objResults
Const OUTPUT_FILE = "c:\CompanyList.txt"
Const fsoForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objResults = DTSGlobalVariables("gResults").Value
Set objStream = objFSO.OpenTextFile(OUTPUT_FILE, fsoForWriting, True)
'Loop through the records and output each one
'to a file.
While Not objResults.EOF
strRecord = "Relatiecode #" & objResults.Fields(0).Value & _
"JA/NEE" & objResults.Fields(1).Value
objStream.WriteLine (strRecord)
objStream.WriteBlankLines (1)
objResults.MoveNext
Wend
If Err.Count = 0 Then
Main = DTSTaskExecResult_Success
Else
Main = DTSTaskExecResult_Failure
End If
End FunctionHi
"superbaby@.gmail.com" wrote:

> I have create a DTS package, This job is fist connect to database, and
> then excute a SQL query, then use the VB ActiveX to create a procedure
> to store the sql result to a text file. I ran the package there is no
> porblem with query.But the second step for output the result to text
> file have problem. The test fiel become 200mb big and cannot open. I
> would like to know if there something wrong with my programming.
> '***************************************
*******************************
> ' Visual Basic ActiveX Script
> '***************************************
*********************************
> Function Main()
> On Error Resume Next
> Dim strRecord
> Dim strEmailBody
> Dim objFSO
> Dim objStream
> Dim objResults
> Const OUTPUT_FILE = "c:\CompanyList.txt"
> Const fsoForWriting = 2
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objResults = DTSGlobalVariables("gResults").Value
> Set objStream = objFSO.OpenTextFile(OUTPUT_FILE, fsoForWriting, True)
> 'Loop through the records and output each one
> 'to a file.
> While Not objResults.EOF
> strRecord = "Relatiecode #" & objResults.Fields(0).Value & _
> "JA/NEE" & objResults.Fields(1).Value
> objStream.WriteLine (strRecord)
> objStream.WriteBlankLines (1)
> objResults.MoveNext
> Wend
>
> If Err.Count = 0 Then
> Main = DTSTaskExecResult_Success
> Else
> Main = DTSTaskExecResult_Failure
> End If
> End Function
>
You don't seem to be closing the file and setting your cleaning up the
objects by setting them to nothing for examples see
http://www.sqldts.com/303.aspx
I am not sure if it will not solve the problem though!!
John