locked
new to c# need some help with string literals

    Question

  • hi

     i need some help with executing a SSIS Package through c#

    Very Very urgent!!!!!!!!!!

    I have two variables

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

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

    i am executing this :

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

    path value is correct. but i get error at conn variable

    i get the following result while executing in sql

    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;\"'

    but if i have one more set of qoute before DataSource and at the end. it works fine in sql but not through c# how to do i get that pair of qoutes

    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;"\"'

    Any help appreciated

    Thanks,

    Ja

    Tuesday, August 08, 2006 8:56 PM

All replies

  • I don't know if this helps, but try adding the @ (at symbol) before the string and opening quote marks and remove the double quote marks with the backslash

    example:

     

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

    Make sure that the command line is correct as I may have removed perhaps an additional backslash

    Tuesday, August 08, 2006 9:28 PM
  • 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

     

    Tuesday, August 08, 2006 11:39 PM