Introduction
Once upon a time my examination result was published online first, on that time
I was totally unknown about the working process of internet and even computing.
The main reason, I was very remote villager. But today I have created lots of
web applications where we search record or say result from huge database. Now I
would like to share this experience to all my friends. Let's take a look on the
process.
Perquisite
To learn this article you should have the basic knowledge of ASP.Net and SQL
Server Database. Because in this article, will not explain the technique to
create SQL Database. Only we cover the entity and attribute details and you have
to create it yourself.
Requirements
Create a web application which has the following things:
- Index.aspx (this page will help us to insert the record in database)
- Index.aspx.vb
- Result.aspx (this page will help us to find the particular record)
- Result.aspx.cs
- web.config (this will hold the configuration of database that is credentials of database)
- App_Data (this is folder for Database)
Create a Database as per details given below:
Database Name: myDb.mdf
Table Name: myTb
| Column Name | Data Type | Allow Nulls |
| roll | int | Not Checked |
| name | varchar(50) | Not Checked |
| address | varchar(100) | Not Checked |
| result | char(10) | Not Checked |
Here is screenshot of my database:
Connection-string in web.config file
There are couples of ways to configure the database but I have used as follows:
<connectionStrings>
<add
name="myDbConnectionString1"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\myDb.mdf;Integrated
Security=True;User Instance=True"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
If you want to create your own configuration in web.config file, then simply
drag the table from Database Explorer on form and now open web.config file. Now
you don't have to type above coding for your configuration. You can delete the
dragged items from web form, web.config file will not be effected now.
Index.aspx page
<%@
Page Language="VB"
AutoEventWireup="false"
CodeFile="Index.aspx.vb"
Inherits="_Default"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
>
<head
runat="server">
<title>Searching
Any Record From Database In ASP.Net</title>
</head>
<body>
<form
id="form1"
runat="server">
<div>
<span
style="font-size: 14pt;
color: #0000ff; font-family: Verdana; text-decoration: underline">
<strong>Searching
Any Record From Database In ASP.Net</strong></span><br
/>
<br
/>
<br
/>
<table
style="width: 345px"
bgcolor="#dcdcdc">
<tr
bgcolor="#008b8b">
<td
colspan="3">
<br
/>
<div
style="width: 286px;
height: 2px">
<strong>Insert
the students result here</strong></div>
</td>
</tr>
<tr>
<td
style="width: 26px">
</td>
<td
style="width: 86px">
<br
/>
</td>
<td
style="width: 134px">
</td>
</tr>
<tr>
<td
style="width: 26px">
Roll</td>
<td
style="width: 86px">
<asp:TextBox
ID="roll"
runat="server"></asp:TextBox></td>
<td
style="width: 134px">
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="roll"
ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td
style="width: 26px">
Name</td>
<td
style="width: 86px">
<asp:TextBox
ID="name"
runat="server"></asp:TextBox></td>
<td
style="width: 134px">
<asp:RequiredFieldValidator
ID="RequiredFieldValidator2"
runat="server"
ControlToValidate="name"
ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td
style="width: 26px">
Address</td>
<td
style="width: 86px">
<asp:TextBox
ID="address"
runat="server"></asp:TextBox></td>
<td
style="width: 134px">
<asp:RequiredFieldValidator
ID="RequiredFieldValidator3"
runat="server"
ControlToValidate="address"
ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td
style="width: 26px">
Result</td>
<td
style="width: 86px">
<asp:DropDownList
ID="result"
runat="server"
Width="154px">
<asp:ListItem>PASS</asp:ListItem>
<asp:ListItem>FAIL</asp:ListItem>
</asp:DropDownList></td>
<td
style="width: 134px">
</td>
</tr>
<tr>
<td
style="width: 26px">
</td>
<td
style="width: 86px;
text-align: left;">
<br
/>
<asp:Button
ID="Button1"
runat="server"
Text="Insert"
Width="91px"
/><br
/>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$
ConnectionStrings:myDbConnectionString1 %>"
InsertCommand="INSERT
INTO myTb(roll, name, address, result) VALUES (@roll, @name, @address, @result)"
SelectCommand="SELECT
roll, name, address, result FROM myTb">

Đăng HảiPosted Jun 8, 2018, 3:09 AM
Thank you so much!!!
anand chauhanPosted Aug 27, 2013, 8:36 AM
how to create search engin like just dial
vasant kataraPosted Apr 5, 2013, 3:37 PM
how to store image into database and then after how to fetch on perticular box please help me..
Bhushan TaydePosted Jun 14, 2011, 5:35 AM
sir, i have make a project about student information and display educational information. how can i calculate percentage pls help me [email protected]
Mukesh RajaramPosted Apr 29, 2011, 8:26 AM
thanks sir
Pravin AryaPosted Mar 30, 2011, 4:14 AM
Hi Abhimanyu, Thnx for helping us...
abraham assefaPosted Nov 26, 2010, 12:20 PM
thank you alot guys , i really love this web site since it contains oceanic amount of knowlege. namaste
BELLO GOLAHANPosted Nov 1, 2010, 5:27 AM
thaks for this article,it really helps.pls how can search for a record with columnname(name) in the program above.my mail address is [email protected] . thanks for the article