Using OLE Object we can save images in Access Database, in this example we will select a image and save that image in Access database using ASP.NET.
First we will start creating a table in access database.
Create a table ImageTable with following fields
- ID AutoNumber (Primary Key)
- ImageName Text
- ImageValue OLE Object
Now create a WebApplication and add following controls on the Web Form
- Upload Control
- Button for uploading image and saving into database
- DropdownList for listing all the images in Dabase Table
- Button for saving the image into a folder
- Image to show the image save on the disk
Initially we will fetch the image names which are already saved in the table and show in the drop down list, for that use Page_Load method and insert following code
now double click on upload image button and add following code, in following code we are just reading the image into stream of bytes and we are storing into the database
To resave the image on to the disk we will use following code, once we save image from database to disk we will show that image in image1 control.
now we are ready with our code just build, run and test
hope this helps
Tags: Save images in Access Database, ASP.NET, Save images in Database
April 10th, 2009 | Posted in ASP.NET, Save Images into Access Database | No Comments
Following example I am trying to explain how we can request to a URL from our coding and read the Header content of the response.
Create a web application and add a Textbox and a Button to Default.aspx and double click on the button and add following code.
protected void Button1_Click(object sender, EventArgs e)
{
try
{
//Create a object for HttpWebRequest using this request object we will
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(TextBox1.Text);
//request a response from the URL
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
//Reading all header content of response
for (int i = 0; i < res.Headers.Count; i++)
{
Response.Write(res.Headers.AllKeys[i] + ” : “ + res.Headers[i].ToString() + “<br>”);
}
}
catch (Exception ex)
{
//Catch if there are any exception
Response.Write(ex.Message);
}
}
Now we are ready with code, lets build, run and test
Hope this helps.
SatishKumar J
Microsoft MVP(ASP.NET)
Tags : HttpWebRequest, HttpWebResponse, Headers
March 29th, 2009 | Posted in ASP.NET | No Comments
Normally when we use calendar control in asp.net we see that calendar control occupies lot of space and selecting a date will cause a post back.
To avoid that problem we can use AJAX to select a date from calendar control with out any page post back and hiding the calendar control will save lot of space.
Now lets create a web application and add a script manager and a update panel control, now under update panel add text box, button and a calendar control as shown the below screen shot and make calendar control visible property to false

Now lets write logic in .cs file for that double click on Button and add following code
Calendar1.Visible = true;
and double click on calendar control and add following code
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
Calendar1.Visible = false;
}
Now we are ready with our code, lets run build and test.

Hope this helps.
March 25th, 2009 | Posted in ASP.NET | No Comments
ASP.NET is now live and you can download that from http://go.microsoft.com/fwlink/?LinkId=144444 and you can access the documentation from http://go.microsoft.com/fwlink/?LinkId=145989.
Tags : ASP.NET MCV, .NET C#, ASP.NET 3.5
March 25th, 2009 | Posted in ASP.NET | No Comments
In this example I will explain how we can use external images in .rdlc reports.Create a Web Application.
Right click on Project in Solution Explorer –> Add New Item – Select a .rdlc Report
Now Drag and Drop a image control in Header section in the Report.rdlc
Go to Report Menu in Visual Studio and Select Report Parameters –> and Add a parameter with name Path
Now we will set this path parameter to our image’s value property and provide the value at run time, select image and properties(F4) and set following values to Source and Value properties
Source = External and Value = !Path.value
Now create a Image folder in your solution and Add some images to that folder.As I am only concentration on showing images on the report in this example I am not loading any data on to the report.
Now open Default.aspx page and add MicrosoftReportViewer Control and set MicrosoftReportViewer control source to Report1.rdlc
Now we are ready with design part,
One of the most important thing while displaying external images is to set EnableExternalImages perperty of MicrosoftReportViewer.LocalReport’s to True, this will allow us to show external images on the .rdlc reports
And also we need to set the Path parameter value so that image will be displayed on the report for that we need to all following code to Page_Load event
Now we are ready with our code, just build and run and test
Hope this helps.
Tags : .rdlc report, external Images, ASP.NET
March 16th, 2009 | Posted in ASP.NET | 2 Comments
Web 2.0 much discussed term nowadays; what is Web 2.0 lets us first define what Web 1.0 and then come to Web 2.0.
Web 1.0: Normal web applications which provide some information and very minimal user interaction with the application, this is server centric
Web 2.0: A rich Web application which provides more interactions with user, and user can customize his content etc, and this is user centric.
One of the examples for Web 2.0 is twitter.com, in this web site you can share photos, customize view etc.
Microsoft has come with some starter kit for implementing Web 2.0 applications and it is called Kobe.
They are providing some good information how to plan and build Web 2.0 application, you can find more details, examples and some videos at following link.
http://msdn.microsoft.com/en-us/architecture/bb194897.aspx
March 11th, 2009 | Posted in ASP.NET | No Comments
In this example I am Using AJAX to show how you can display data using AJAX.This will work very fast and you will see there is not page reload is occurring
Create a Web Application and modify Default.aspx html content
I am adding Script manager control and a Update Panel control, Under Update panel control add 2 labels and 2 dropdownlist control and gridview like below
Once Modify Default.aspx, open Default.aspx.cs and modify the Page_Load and add following code.
Now we will add code to fetch the Orders by particular Employee, for that we need write code in DropDownList1_SelectedIndexChanged event, please add following code
Now we will fetch the order details of selected order number for that we need to add the following code in DropDownList2_SelectedIndexChanged event
Now we are ready with over code, just build, run and test
Hope this help you.
February 27th, 2009 | Posted in ASP.NET | No Comments