Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi 4nds,

I created a form with some controls and connected it with database. Then, in another form i would like to display the particular employee records by giving a parameter through search button.

please help me to find it out.
Posted
Updated 17-Jan-12 19:07pm
v2

hi,

1) first of all get the employeeId of that perticular employee
then write a query according that,

2) connect to the database
3) get the results into dataset
4) provide a dataset as a datasource to gridview with whatever the details you want

Thanks
 
Share this answer
 
Comments
Yugma9 18-Jan-12 0:58am    
hi thanks for your answer..

but the thing is i would like to display the records in the form directly.. not in a gridview r sumthing else..
is it posible r not????
amolpatil2243 18-Jan-12 1:39am    
you have to display it in only server side data control.

but if you want to directly display, it is so much lenthy process
It can be better if you use datagridview to show employee details

use onbuttonclick
C#
private void button3_Click(object sender, EventArgs e)
       {
           try
           {
               string strdate = "select *from emp where emp name like '%'+@name+'%'";
               SqlCommand cmddate = new SqlCommand(strdate, Db.GetConnection());
               cmddate.Parameters.AddWithValue("name",textbox1.Text);

               SqlDataAdapter dadate = new SqlDataAdapter(cmddate);
               DataTable dtdate = new DataTable();
               dadate.Fill(dtdate);
               dataGridView1.DataSource = dtdate;
               dataGridView1.Refresh();
           }
           catch (Exception ex)
           {
           }
       }
 
Share this answer
 
Comments
Yugma9 18-Jan-12 1:06am    
ok,
string strdate = "select *from emp where emp name like '%'+@name+'%'";

here m not only passing the name .
i provided a combo box for searching.
in that i gave column names of the table.
so client can choose anything from them, and then they can pass the parameter accordind to the selected column name.

so please send the code for that
Yugma9 18-Jan-12 1:11am    
1. Should select the column name from combo box eg; contact no.
2. must pass the value in the text box eg; 123456789
3. now after clicking the search button , the record related to that contact no should display in the form.
uspatel 18-Jan-12 1:11am    
try this
string strdate = "select *from emp where '+combobox1.Text+' like '%'+@name+'%'";
I did'nt try this,but hope it can work.
Yugma9 18-Jan-12 1:54am    
yah, but in that combo box ,name is not only there many things are there.
instead of '+@name+'%'";
what i hav to write...
uspatel 18-Jan-12 1:57am    
name is nothing , it only parameter(that is bind with textbox) that will be work with respect of combobox.
as if you selct contactno then query like
select *from emp where contactno like [value in textbox]

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