Monthly Archives: June 2012

Connect to IBM DB2 & Read Image Column Using VB.Net

IBM DB2 LUW or DB2 Linux Unix Windows is one of a recommended RDBMS software used by many organizations.
By its name this DB2 LUW is a platform independent because it can be run on Linux, Windows, Solaris, Mac OS.

IBM has free version of DB2 LUW which is DB2 Express-C. Unlike another RDBMS, DB2 Express-C does not have any time restrictions or database size limitations.
So this free version can be used in production environment.

Because of platform independent we can install DB2 server on Linux as database server to avoid virus infection. Since MS Windows is more widely used (at least in my country) then we also can use MS Windows to run client application (VB.Net) that connect to DB2.
I will show you example using VB.Net to work with DB2 and also to get image data.

DB2 .Net Data Provider

IBM provides .Net Data Provider for DB2. It is located on installation of DB2 folder like C:\Program Files\IBM\SQLLib\Bin\netf20\IBM.Data.DB2.dll. I added this library file to project’s reference.
I use DB2Connection class to establish connection to DB2. DB2DataAdapter to retrieve recordset and DB2Command to execute sql query.

Example

I use SAMPLE database and populate DataGridView with Employee data. If employee has a photo then it will be showed on picture box.
Please refer to this pic below:


Continue reading

Accessing Database Record in Sql Server Reporting Service (SSRS) Custom Code

SSRS can use Custom Code to have more flexible way to achieve complex tasks like calculation, conditional result, and also accessing records on database.

Custom Code use System.Data Class to work with database which means read a records. This class have to be registered in SSRS config file and also have to be referenced in Report file.

In this blog post I will show you on how to read sql server record using SSRS Custom Code. I use SQL Server 2005 Express Edition and the database is AdventureWorks sample database.
I will list all Product Category with count number of product in specific category. I use Custom Code to calculate how many of product in category.

Here’s how to make Database enabled SSRS Custom Code:
Continue reading

Creating and Using TextBox in Rows Like An Array To Update Multiple Records At Once In Asp.Net

Updating multiple data at multiple rows in table is very often process on web application. Especially on interal / private system.

We have to make a grid like excel to do that. User inputs their data into multiple textboxes in rows / cells then clicks submit button to update those data at once.

Asp.Net server input control has many ways to access list of textboxes. Not only using array like asp classic do but we can do it using repeater / listview / gridview / table control as a grid creator and use FindControl method to access control inside grid including textboxes.

I have an example to update email of many customers so that when submit button is clicked then related email textboxes text will be stored on database.

I use VS 2010 and my local SQL Express 2005 with Northwind sample database to make this example.
Continue reading

Open an Url on Asp.Net ModalPopupExtender Ajax Toolkit And Alternative Approaches


Traditional javascript using window.open(url) function to open an Url on new browser window.
Developers can post a form to new window or build a data entry page. window.open(url) function is simple but if it opens new browser several times then overall application could become overwhelming.

We can use ModalPopupExtender instead of window.open function. ModalPopupExtender is an Ajax Control Toolkit to create a modal popup. Modal popup is a dialog box that always on top of a page. You cannot access parent page if modal popup still appear so you need to close it first.
I already have a blog post explaining and showing example about ModalPopupExtender, please follow this Create a PopUp Dialog with ModalPopupExtender AjaxControlToolkit

ModalPopupExtender usually has a Panel Control and inside this Panel we can have any control like label, textbox, button etc. ModalPopupExtender usually has an OK and Cancel button inside Panel.
Those OK and Cancel buttons actually close the modal popup.

The question is how can we open an Url and show it inside Modal Popup? We can just fill in the Url’s HTML source code string into Panel inside the Modal Popup.
So that we can have dynamic content on that modal popup

One way to get Url’s HTML source code is using WebRequest Class. This WebRequest Class can get the response stream of Url and we convert it to string using StreamReader Class.

Continue reading