ADO.NET ARCHITECTURES…

Assalamualaykum Wr Br…Today we understand few thing about ADO.NET architectures then we explore the theory and practical tour. ADO.NET Disconnected architecture is a method of retrieving a record set from the database and storing it giving you the ability to do many CRUD (Create, Read, Update, Delete) operations on the data in memory, then it can be re-synchronized with the database when reconnecting. A method of using disconnected artitecture is using a DataSet.

Connected architecture is when you constaintly make trips to the database for any CRUD operation you wish to do. this creates more traffic to the database but is normally much faster as you should be doing smaller transactions.
Now we start our tour of practice with the following design view as shown:
disconnected1
When you click the Button then in new line Gridview is populated with data in which Disconnected ADO.NET class named SqlDataAdapter is used which executes the command, fills data in DataSet and this DataSet is assigned to GridView as Data Source and finally Binded to Grid. Button_Click Code is demonstrated as below:
disconnected2

Finally the Output of the above code is shown below:
disconnted3
Thats all of the day…Hope Enjoyed the post…
Jazakallah Khair…

Bind Data to Grid in ADO.NET

Assalamualaykum Wr Br… Today we explore how data can be populated on GridView…
Let us first we understand what is GridView?
To be very specific, GridView is a Control which is highly used to display data in tabular format. In detail,
The GridView control is the successor to the DataGrid and extends it in a number of ways. With this GridView control, you could display an entire collection of data, easily add sorting and paging, and perform inline editing. In addition to just displaying data, the GridView can be used to edit and delete the displayed data as well. Now lets start our practical session, where I import SqlClient,OracleClient or OledbClient dlls in my project and in addition to hard coding C# standard as using System.Data.SqlClient; or VB Standard as imports System.Data.SqlClient
When you want to connect to Oracle Database, you need to download Oracle.DataAccess dll which is available @ http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html which available in ODAC package. Please follow the Design Pattern as shown:

grid_design
The respective C#.NET code for Button click which populates data in GridView is shown:
grid_codeUpon Executing the above project the following output appears after button click:
output_grid
Please note that I used DataReader which is Disconnected data architecture which we deal it in coming posts…Hope you might enjoy this post…Till Then have a good day…

Jazakallah khair…

Working With ADO.NET – 1

Assalamualaykum Wr Br…Today we start our journey towards ADO.NET. ADO refers to ActiveX Data Object
ADO.NET provides a bridge between the front end controls and the back end database. The ADO.NET objects encapsulate all the data access operations and the controls interact with these objects to display data, thus hiding the details of movement of data.

The following figure shows the ADO.NET objects at a glance:
ado.net_objects

We start a sample application that demonstrates the connection establishment to Database from Front-End.
Design the UI as follows:
ado2
The following code demonstrates the logic:
ado1
The output can be shown as:
ado3
Hope you Enjoyed the journey first phase..There’s a lot more…till then Enjoy coding…

Upload files in ASP.NET

Assalamualaykum Wr Br…Today we make tour of the ASP.NET FileUpload Control. Asp.Net FileUpload Control allows users to upload files on the web server. It automatically sets the encoding of the form. It allows the users to browser for and select the file to be uploaded, providing the Browse Button and TextBox for entering the File Name. Once the User has entered the File Name in the TextBox by typing the Name or Browsing, the SaveAs method of the FileUpload Control can be called to save the file to the disk.

The basic syntax of the FileUpload Control is:

The FileUpload Class is derived from WebControl Class, and inherits all its members. There are some read only properties which can be stated as:
1. FileName.
2. HasFile.
3. FileBytes.
4. FileContent.
5. PostedFile.

The posted File is encapsulated in an object of type HttpPostFile, which could be accessed through the PostedFile Property of the FileUpload Class.

The HttpPostedFile has Following properties:
1. ContentLength
2. ContentType
3. FileName
4. InputStream
Now, Let us start the Practice Session…Design the ASP.NET page as shown below:
fileupload

The Above Design view can be coded as shown below:
fileup1

The Code Behind for the button SAVE is shown as:
codefile
When this Program is executed we get the following output:
outputfile
outputfile1

Hope enjoyed this tour…Jazakallah khair

Zip your files using C#.Net…

Assalamualaykum Wr Br…
Today we walk through the code for compressing files in C#.Net 4.5 Framework using Zip.
There are many formats that are available in C#.Net like Deflate, GZip, Zip and many more…We focus mainly on Zip format now in later posts we try to follow other formats inshallah..
Before we start our coding, First add the reference of WindowsBase.dll” in your solution. In case if you couldn’t find it in .Net tab of references window then go to Browse tab and try to find it in the directory as shown:
“C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\”
One more thing we need to do is Import a System.IO.Packaging in your using block.
The following image shows the code:
coompress
The output of the above program is shown as:
compress_output
hope it is helpful to anyone…
Jazakallah khair

Excel file Techniques…

Assalamualaykum Wr Br…
A nice and cute trick with excel I found quite interesting and thought to share it and here it is:
1. I have a excel file as shown below:
excel
2. Need to append single quote at the begining and end of the data as ‘Aejaaz’..Which can be done as:
a. Click any cell(here I clicked B1 cell). And write the formula in formula bar as =”‘”& F1& “‘” and hit enter key.
excel1
b. Now drag the B cell and get the result as expected as shown below:
excel2
Jazakallah Khair…