Friday, February 24, 2012

c# UI Escape character problem to execute command line

Hi!

Thanks For your reply!

but this is very urgent please help!!!!!!!

I need one more help in this issue. what if i do not need any \ "

for e.g: i am trying to set conn string and varaible value

jobCommand = new SqlCommand("xp_cmdshell 'dtexec /f \"" + path + "\" /Conn \"" + Packconn + "\" \"" + connect + "\" '",cconn);

i am getting some value like this :

CommandText "xp_cmdshell 'dtexec /f \"D:\\SSISProject\\Integration Services Project1\\ArchiveMainMultiTables.dtsx\" /Conn \"SE413695\\AASQL2005.TestDB;\" \"Provider=SQLNCLI.1;Data Source=SE413695\\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;\" '" string

I do not need the highlighted escape characters in it. what should i do?

i need some thing like this :

xp_cmdshell 'dtexec /f "D:\SSISProject\Integration Services Project1\ArchiveMainMultiTables.dtsx" /Conn SE413695\AASQL2005.TestDB;"Provider=SQLNCLI.1;Data Source=SE413695\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;"'

Thanks,

Jas

C# has support for unescaped strings. Anything you put in them will appear as is. The only thing to escape is the " and you do that by using two ("")

You must append an @. to the front of the string to tell the compiler that is is unescaped.

So your code would look like this:

jobCommand = new SqlCommand(@."xp_cmdshell 'dtexec /f """ + path + """ /Conn """ + Packconn + """ """ + connect + """ '",cconn);
|||

hi!

Need some urgent help

I am not using @. symbol cos i need to use \ character.

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

string conn = @."Data Source=SE413695\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;";

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

Path works correctly with ur previous answer but the conn as some thing liek this

Which is not working correclty i am getting this value

xp_cmdshell 'dtexec /f \"D:\\SSISProject\\Integration Services Project1\\ArchiveMainMultiTables.dtsx\"/Set \package.Variables[User::connectst].Properties[Value];\"Data Source=SE413695\\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;\"'

error near spaces when i execute SQL

Argument "\package.Variables[User::connectst].Properties[Value];"Data "Source=SE413695\\AASQL2005;Initial" "Catalog=TestDB;Provider=SQLNCLI.1;Integrated" Security=SSPI;"" for option "set" is not valid.

I need to get some thing like this through c#

xp_cmdshell 'dtexec /f \"D:\\SSISProject\\Integration Services Project1\\ArchiveMainMultiTables.dtsx\"/Set \package.Variables[User::connectst].Properties[Value];\""Data Source=SE413695\\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;"\"'

Please help me with this

thanks,

Jasmine

No comments:

Post a Comment