Observe the WHERE, ORDER BY, and the Advanced buttons. Choose the data source and format the control using Auto Format option.
These buttons allow you to provide the where clause, order by clause, and specify the insert, update, and delete commands of SQL respectively. (7) After this the formatted Grid View control displays the column headings, and the application is ready to execute.
Note that this connection requires a Data Source, DB File Name, and provider name.
(4) Once the connection is set up, you may save it for further use.At the next step, you are asked to configure the select statement: (5) Select the columns and click next to complete the steps.Open the solution explorer right click on website add new item – open item templates select SQL Server Database click on add button after that show message box click on “Yes” button.Now follow the following steps to create the table: Figure 2: SQL Server Database Table with given Columns After create database go on page and double click on Submit Button and write down some code: Listing 2: C# code to insert data in database Now you have to create a web.config connection entry to connect to database.In the preceding table, the Image Name column name is used to store the name of an image file and the image is used to store the image file . Now let us start to create an application to upload and display image files step-by-step.
In the preceding image, we can see the extension file, now keep the name as it is or change it as you wish, I have kept it as it is because the next time you can easily remember it and click on the add button, now after that your Solution Explorer will look as in the following In the preceding Handler1cs file, first I have created the object of the cs class to use the connection method and variable to avoid the repetition of code because in the cs file we also need the same connection method and string variables that are in the cs class.
Open your instance of Visual Studio 2012, and create a new ASP. Name the project “MYSQLCRUDApplication ", as shown in the following figure: In the code behind file (cs) write the code as in the following. Now, enter the student data insert and Grid view Show Data. Now, select the Student then show the data Text Box and update the data shown in the Message box “Student Data update successfully”.
Now, delete the Student data shown in the Message box “Student Data Delete Successfully”. If you have any other questions then please provide your comments below.
Now, the most important thing is to specify the image URL property of the image control that display the images from the database, so let us see how to do it.
Summary Now we have learned how to upload images to a database and display those images in Grid View.
I have often been asked how to upload images to a database and displaying them from the database using ASP. So to satisfy those the requirements I decided to write this article especially focusing on beginners and those who want to learn how to upload images to a database and display those images.