hi!
din't work. I need some thing in C# that can execute like this:
This works in SQl Query perfectly.
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;"\"'How do we interpret in c# currently i have some thing like this which is not correct i need to fix this to work in C#
string
conn = @"""Data Source=SE413695\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;""""";path = @"""D:\SSISProject\Integration Services Project1\ArchiveMainMultiTables.dtsx";
jobCommand = new SqlCommand(@"xp_cmdshell 'dtexec /f " + path + "\" /Set \\package.Variables[User::connectst].Properties[Value]; " + conn + "\"'", cconn);
Thanks,
Ja

String literal problem
Inaki Ayucar
i suggest you put a breakpoint in to check your string value before you execute it as an SQL command so you can see where you went wrong. I would also suggest you use placeholders for any variables in your string so that it is more readable then concatenating many strings and variables.
for example.
// instead of
String test = "The file path is: " + path + "\\" + filename;
//use
String test = @"The file path is: {1}\{2}";
test = String.format(test, path, filename);
Rocky79
i found out the problem but i don'w know how to solve it
this is what happens
path = @"""D:\SSISProject\Integration Services Project1\ArchiveMain.dtsx"; this string has \ and spaces inbetween intergration and services and works fine.
but if i send this string
string
conn = @"""Data Source=SE413695\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;"; This string is much similar to the other one.I am executing this statement: in c#
jobCommand =
new SqlCommand(@"xp_cmdshell 'dtexec /f " + path + "\" /Set \\package.Variables[User::connectst].Properties[Value];" + conn + "\" '", cconn,transaction);in sql i am trying to execute the outcome as:
xp_cmdshell 'dtexec /f \"D:\\SSISProject\\Integration Services Project1\\ArchiveMain.dtsx\" /Set \package.Variables[User::connectst].Properties[Value];\"Data Source=SE413695\\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;\"' which doed not execute because
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.
but if i added an extra qoute then it executes fine.xp_cmdshell 'dtexec /f \"D:\\SSISProject\\Integration Services Project1\\ArchiveMain.dtsx\" /Set \package.Variables[User::connectst].Properties[Value];\""Data Source=SE413695\\AASQL2005;Initial Catalog=TestDB;Provider=SQLNCLI.1;Integrated Security=SSPI;"\"'
How do i solve it in C# and added these extra qoutes
Thanks
Jas
arikve
Please do not cross post:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=618901&SiteID=1