C# code required urgently

Jun 1 2015 5:37 AM
Hi folks,
 
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace ST_37ea42e2bf564f4f9a848267124b45f1.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
public void Main()
{ // TODO: Add your code here
String sDatabaseConnectionString = @"PUNITP347138D.Ankit";
// Here I trying to use Variable Instead of C:\HCS\Data\cd_catalog.xml for file location
String sXMLFile = @"C:\Users\ankit_rohatgi\Desktop\Output 5-25-2015 6-53-01 PM - Copy.xml";
try
{
using (SqlConnection oConn = new SqlConnection(sDatabaseConnectionString))
{ // Open the Connection to the database oConn.Open();
// Instanciate a new DataSet using (
DataSet dsTemp = new DataSet();
{ //Read the XML file into the DataSet dsTemp.ReadXml(sXMLFile);
//Instante a datatable from the DataSet using (
DataTable dt = dsTemp.Tables[0];
// Instanciate a new SqlBulkCopy object using the connection using (
SqlBulkCopy sb = new SqlBulkCopy(oConn);
{ // Assign BatchSize
sb.BatchSize = 50;
// Assign Destination Table Name
// Here I trying to use Variable Instead of C:cd_catalog for table
sb.DestinationTableName = "OpenPages";
sb.WriteToServer(dt);
}
}
}
}
// Catch any SQL errors first
catch (SqlException ex)
{
}
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
 
In the above code, how to specify the static file path for XML file i.e input is an XML
 
Thanks
Ankit 

Answers (1)