Click here to Skip to main content
15,888,351 members
Home / Discussions / Database
   

Database

 
AnswerRe: Export Access db to Sql Server db everyday Pin
Eddy Vluggen10-Oct-16 6:58
professionalEddy Vluggen10-Oct-16 6:58 
QuestionIdentity_Column Pin
Member 111616253-Oct-16 19:43
Member 111616253-Oct-16 19:43 
AnswerRe: Identity_Column Pin
Chris Quinn3-Oct-16 23:11
Chris Quinn3-Oct-16 23:11 
AnswerRe: Identity_Column Pin
Swinkaran4-Oct-16 1:17
professionalSwinkaran4-Oct-16 1:17 
QuestionSQL Server Reporting Services Query to Get Stored Procedure Name for Shared Dataset Pin
David_4129-Sep-16 11:48
David_4129-Sep-16 11:48 
AnswerRe: SQL Server Reporting Services Query to Get Stored Procedure Name for Shared Dataset Pin
Mycroft Holmes29-Sep-16 12:43
professionalMycroft Holmes29-Sep-16 12:43 
GeneralRe: SQL Server Reporting Services Query to Get Stored Procedure Name for Shared Dataset Pin
David_4129-Sep-16 12:51
David_4129-Sep-16 12:51 
QuestionExecuting SSIS Package from C# Console App Pin
indian14328-Sep-16 4:51
indian14328-Sep-16 4:51 
Hi All,

I am executing a dtsx package from C# code, what dtsx package does is, it simply reads data from .txt file and writes into another .txt file. I have two connections "Flat File Connection Manager" and "Flat File Connection Manager 1", I am calling that package with FileWatcher application which invokes when file changes or created etc. But when I am trying to execute the package, its giving me Success message but its not able to create the destination file. But package is able to create the destination file when its executed from SSDT (BIDS) using start debugging but the same package when its called from the C# code, its not generating the destination flat file.

I am not understanding is it a permission issue or something I am missing in my Code?

Can anybody please help me I am searching in google and trying with different combinations, any kind of help would be greatly helpful - thanks in advance.
private static void OnCreated(object source, FileSystemEventArgs e)
{
    // Specify what is done when a file is changed, created, or deleted.
    // get the file's extension
    string strFileExt = (Path.GetExtension(e.FullPath) ?? string.Empty).ToLower();
    string directoryFullPath = Path.GetDirectoryName(e.FullPath);

    // filter file types
    if (Regex.IsMatch(strFileExt, @".txt|.csv", RegexOptions.IgnoreCase))
    {
        Package _package = null;
        Application app = new Application();
        string dtsPackPath = ConfigurationManager.AppSettings["SSISPackagePath"];
        _package = app.LoadPackage(dtsPackPath, null);

        _package.Connections["Flat File Connection Manager"].ConnectionString = e.FullPath;
        _package.Connections["Flat File Connection Manager 1"].ConnectionString = directoryFullPath + @"\Test" + DateTime.Now.Year.ToString()
            + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString()
                    + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString()
                    + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".txt";

        //_package.Variables["User::SourceFileName"].Value = e.FullPath;

        //_package.Variables["User::FileName"].Value = directoryFullPath + @"\Test" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString()
        //            + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString()
        //            + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".txt";

        var res = _package.Execute();

        if (res == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success)
        {
            string message = "Package Executed Successfully....";
        }
    }

    while (Console.Read() != 'q') ;
}

Now I did try it by putting OLEDB connection for destination, still when package runs from Visual Studio yields o/p but when run from the Console app, it doesn't give me any o/p neither in the o/p file nor in the Database table

Here is the code for writing into Database table
private static void OnCreated(object source, FileSystemEventArgs e)
{
    // Specify what is done when a file is changed, created, or deleted.
    // get the file's extension
    string strFileExt = (Path.GetExtension(e.FullPath) ?? string.Empty).ToLower();
    string directoryFullPath = Path.GetDirectoryName(e.FullPath);

    if (Regex.IsMatch(strFileExt, @".txt|.csv", RegexOptions.IgnoreCase))
    {
        Package _package = null;
        Application app = new Application();
        string dtsPackPath = ConfigurationManager.AppSettings["SSISPackagePath"];
        string sqlServerConnectionString = ConfigurationManager.AppSettings["SqlServerConnectionString"];
        _package = app.LoadPackage(dtsPackPath, null);

        _package.Connections["Flat File Connection Manager"].ConnectionString = e.FullPath;

        //_package.Variables["User::SourceFileName"].Value = e.FullPath;

        //_package.Variables["User::FileName"].Value = directoryFullPath + @"\Test" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString()
        //    + DateTime.Now.Day.ToString()
        //    + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString()
        //    + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".txt";

        _package.Connections["BSCWD725128.DTS_Testing"].ConnectionString = sqlServerConnectionString;

        var res = _package.Execute();

        if (res == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success)
        {
            string message = "Package Executed Successfully....";
        }

        //_package.Connections["Flat File Connection Manager 1"].ConnectionString = directoryFullPath + @"\Test" + DateTime.Now.Year.ToString()
        //    + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString()
        //            + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString()
        //            + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".txt";
    }

    while (Console.Read() != 'q') ;
}
Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."


modified 28-Sep-16 14:15pm.

AnswerRe: Executing SSIS Package from C# Console App - resolved Pin
indian14328-Sep-16 12:09
indian14328-Sep-16 12:09 
Question.mdb file problem Pin
Member 1275753624-Sep-16 6:19
Member 1275753624-Sep-16 6:19 
AnswerRe: .mdb file problem Pin
Mycroft Holmes24-Sep-16 14:49
professionalMycroft Holmes24-Sep-16 14:49 
GeneralRe: .mdb file problem Pin
Richard Deeming26-Sep-16 2:12
mveRichard Deeming26-Sep-16 2:12 
GeneralRe: .mdb file problem Pin
Mycroft Holmes26-Sep-16 12:33
professionalMycroft Holmes26-Sep-16 12:33 
AnswerRe: .mdb file problem Pin
Victor Nijegorodov25-Sep-16 3:31
Victor Nijegorodov25-Sep-16 3:31 
QuestionHow to update Oracle DB from SQL server through link server? Pin
hmanhha22-Sep-16 20:20
hmanhha22-Sep-16 20:20 
AnswerRe: How to update Oracle DB from SQL server through link server? Pin
Richard MacCutchan22-Sep-16 20:53
mveRichard MacCutchan22-Sep-16 20:53 
GeneralRe: How to update Oracle DB from SQL server through link server? Pin
hmanhha22-Sep-16 21:28
hmanhha22-Sep-16 21:28 
GeneralRe: How to update Oracle DB from SQL server through link server? Pin
Richard MacCutchan22-Sep-16 21:30
mveRichard MacCutchan22-Sep-16 21:30 
GeneralRe: How to update Oracle DB from SQL server through link server? Pin
Mycroft Holmes22-Sep-16 21:33
professionalMycroft Holmes22-Sep-16 21:33 
GeneralRe: How to update Oracle DB from SQL server through link server? Pin
Jörgen Andersson22-Sep-16 21:38
professionalJörgen Andersson22-Sep-16 21:38 
AnswerRe: How to update Oracle DB from SQL server through link server? Pin
hmanhha25-Sep-16 21:25
hmanhha25-Sep-16 21:25 
QuestionSQL Server Stored Procedure - Wait for a Table to be Created Pin
David_4122-Sep-16 9:29
David_4122-Sep-16 9:29 
Question[Help] How to create database for control Process in manufacturing company Pin
VaTo Tran21-Sep-16 2:05
VaTo Tran21-Sep-16 2:05 
QuestionIssue on communicating data from two difference system with different names Pin
chaurasiashankar19-Sep-16 19:47
chaurasiashankar19-Sep-16 19:47 
AnswerRe: Issue on communicating data from two difference system with different names Pin
Mycroft Holmes19-Sep-16 20:17
professionalMycroft Holmes19-Sep-16 20:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.