Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one help me out in the code for retrieve a data from database based on user input .Example :user giving input in(radio button ,dropdownlist box).Urgently i need .help me
Posted
Updated 27-May-12 20:44pm
v2
Comments
Mohibur Rashid 28-May-12 3:18am    
So, what is your question? you need help is not a question.
Sandeep Mewara 28-May-12 5:35am    
Whats the issue? Where are you stuck?

1 solution

1.Configure a Connection String in web config..

<configuration>
<connectionstrings>
<add name="MyDbConn">
connectionString="Server=MyServer; Database=pubs; User Id=MyUser; password= P@ssw0rd"
providerName="System.Data.SqlClient" />




2.Then use the following code..

SqlConnection ObjSqlConnection=new SqlConncetion();
ObjConnection.ConnectionString=ConfigurationManager.ConnectionString["MyDbConn"].tostring();
ObjSqlConnection.open();
SqlCommand ObjSqlCommand=new SqlCommand("Name of the stored Procedure",ObjSqlConnection);
ObjSqlCommand.Parameters.Add("Input Name in stored Procedure",DropDownList.SelectedItem.ToString());
ObjCommand.CommandType=CommandType.StoredProcedure;
ObjCommand.ExecuteReader();
while(Reader.Read())
{
//Get What value u needed from the stored procedure result through the index;
}
ObjSqlConnection.close();


I hope u understood....
 
Share this answer
 
v2
Comments
nirmaljayamani 28-May-12 4:47am    
ya i understand . but my output show empty page .Plz check my code and tell me that error

propery.jsp :
<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
<html>

<head>
<title>Property Form</title>
<style type="text/css">


.img{
style=width:400px;height:300px;-webkit-border-radius: 0px 0px 1px 4px;-moz-border-radius: 0px 0px 1px 4px;border-radius:

0px 0px 1px 4px;border:4px solid #6F706C;background-color:#FAF7F0;-webkit-box-shadow: #B3B3B3 8px 8px 8px;-moz-box-shadow:

#B3B3B3 8px 8px 8px; box-shadow: #B3B3B3 8px 8px 8px;
}

div.img
{
margin: 2px;
border: 1px solid black;
height: auto;
width: auto;
float: left;
text-align: center;
}
div.img img
{
display: inline;
margin: 3px;
border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #000000;}
div.desc
{
text-align: center;
font-weight: normal;
width: 120px;
margin: 2px;
}
h1 {
margin-left:-10px;
position:absolute;
z-index:2;
background:url(../images/manoj6.gif) 0 0 no-repeat;
height:97px;
padding-left:191px;
padding-bottom:30px;
left: 13px;
top: -16px;
width: 481px;
}



#header { background:url(../images/header.jpg) repeat-x; width:100%; height:130px;position:relative; z-index:10; }

#header_wrap { width:980px; height:111px; margin:0 auto;}


#menu {padding:20px 0 0}
#menu li {padding:26px 7px 23px 4px;margin-left:30px;float:left;color:#fff;}
#menu .end {background:none;padding-right:0}
#menu li

a{display:inline-block;overflow:hidden;font-size:21px;color:white;line-height:1.2em;text-decoration:none;letter-spacing:-1px

;text-align:center}
#menu ul li a:hover, #menu #menu_active a {color:#00008B}
#menu li

a{display:inline-block;overflow:hidden;font-size:21px;color:white;line-height:1.2em;text-decoration:none;letter-spacing:-1px

;text-align:center}




</style>
</head>

<body >


<form ACTION="properydb.jsp" METHOD="POST">

<fieldset>



<div id="header">
<div id="header_wrap">


</br>
<ul id="menu">
<li>Home</li>
<li>About Us</li>
<li>Property search</li>
<li>Moving</li>
<li>List with Us</li>
<li>Search Agent</li>
<li class="end">Contact Us</li>
</ul>
</div></div>
<div class="img" >
<img src="images\thumbnail.jpg" alt="Klematis" width="185" height="185" />
<div class="desc">Add a description of the image here</div>
</div>

<div class="img">
<img src="images\thumbnail1.jpg" alt="Klematis" width="185" height="185" />
<div class="desc">Add a description of the image here</div>
</div>

<div class="img">
<img src="images\thumbnail3.jpg" alt="Klematis" width="185" height="185" />
<div class="desc">Add a description of the image here</div>
</div>


<frameset>
<table height="400" width="325px" align="right" border=0 style="background-color:white;">
<th bgcolor="white" colspan=2>
Search Options
<br>
</th>



<tr><td align=center>Search Type:</td>
<td><input type="radio" name="sa" >Buy</input>


<input type="radio" name="sa" >Rent</input></td>
</tr>

<tr><td align=center>Type:</td><td>    <select name="typ" ><option>choose

type</option><option>Appartment</option><option>Home</option><option>Flats</option><option>Offices</option><option>land<option>Commercial properties</option></select>
</td></tr>

<tr><td align=center>State:</td><td>    <select name="region" >
<option value="0">«Choose region»</op

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900