Hey Reader, I wrote a .Net console application to read data from SQL Server and update respective table in DB2. So the update query is built dynamically in the code. The connection used was ODBC. When command.ExecuteNonQuery method is processed there occured an exception with the following message.
Message: Message = "ERROR [HY000] [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0666 - SQL query exceeds specified time limit or storage limit."
When googled came acorss this beautiful post. And the solution is in ODBC properties under Performance tab , under Advance, we just need to uncheck the option - "Allow query timeout". the trick worked for me :) Hope it helpz Fauzi
} class aawservice { public DataSet ConvertDataReaderToDataSet(System.Data.Odbc.OdbcDataReader reader) { DataSet dataSet = new DataSet(); do { // Create data table in runtime DataTable schemaTable = reader.GetSchemaTable(); DataTable dataTable = new DataTable();
if (schemaTable != null) { for (int i = 0; i < schemaTable.Rows.Count; i++) { DataRow dataRow = schemaTable.Rows[i];
// Create a column name as provided in Schema string columnName = (string)dataRow["ColumnName"];
// Define Column Type here DataColumn column = new DataColumn(columnName, (Type)dataRow["DataType"]);
//Adding Column to table dataTable.Columns.Add(column); }
dataSet.Tables.Add(dataTable);
// Fill the data table from reader data
while (reader.Read()) { DataRow dataRow = dataTable.NewRow(); for (int i = 0; i < reader.FieldCount; i++) dataRow[i] = reader.GetValue(i); dataTable.Rows.Add(dataRow); } }
else { // No records were returned DataColumn column = new DataColumn("RowsAffected"); dataTable.Columns.Add(column); dataSet.Tables.Add(dataTable); DataRow dataRow = dataTable.NewRow(); dataRow[0] = reader.RecordsAffected; dataTable.Rows.Add(dataRow); } } while (reader.NextResult()); return dataSet; } }
Hi Reader.... We had a requirement to run a same application for different POS(Point of sale) The challenge is to create a single application that takes parameters Store number as input parameter and does the required operation. Doing so we can use the same applicaiton any number of stores.In SSIS we have the module "Execute Process Task" to exectue exe files. I have given the file location in "Executalbe" property under Process Tab.
Regarding the Parameter, First i tried with 'args[0]' in the EXE Created from DotNet Console Applcaition, tried to use it as input parameters.Unfortunately it did'nt work. When i googled found that we can use Console.ReadLine() and get the required parameters in the EXE file And when you need to execute through SSIS(SQL Server Integration Services), we just need to pass the parameter (User Varaiable in SSIS, Eg: User::VarialbeName) in Standard Input Varaible property under Process.
This will pass the parameter dynamically during execution :-)
For a data integration service, I create four DTSX packages. These were generic packages which needs to be executed one after the another. I tried using SQL Server Agent to schedule it as a JOB which has four steps to be executed sequentially. Unfortunately the package which is working fine is visual studio is not working when scheduled. There seems to be some permission issues(had the same issue few days before). As i had users waiting the see the output. I have to find an alternative solution soon. Here is the C# code to run the DTSX from a EXEC file.
Code:
Package pkg;
Application app;
DTSExecResult pkgResults;
Variables varStore;
pkgLocation =@"c:\documents and settings\Path\Filename.dtsx";
app = newApplication();
pkg = app.LoadPackage(pkgLocation, null);
varStore = pkg.Variables;
varStore[YourVariable].Value = 123;
pkgResults = pkg.Execute();
Required NameSpace: The reference of Microsoft.SQLServer.ManagedDTS.dll has to be added and in code -
I had an interesting requirement to generate daily reports based on the accumulated sales data. And this Email will be sent to the respective Managers. Thought it would give a better picture if the email have the appropriate Brand images embedded on necessary places in report.
Following code was very much useful to embed an image in a system generated e-mail through C#.