asp.net - I have a stored procedure how to store its output and display in .NET -


i have form section called search, user enters name , search 3 tables , displays output based on search in exist or not.

in below example taking query input "joe" , lookup in table existence , give tabular format. stuck have created table, sqlprocedure don't know how call sql procedure when user enter name , click on search button, , sqlprocudure called , output displayed without refreshing page.

please code appreciated.

description in eg: have table:

create table table1 (name nvarchar(10)); create table table2 (name nvarchar(10)); create table table3 (name nvarchar(10));  insert table1 values ('joe'); insert table3 values ('joe'); 

and have sql procedure:

select case when t1.name null 'no' else 'yes' end table1       ,case when t2.name null 'no' else 'yes' end table2       ,case when t3.name null 'no' else 'yes' end table3     table1 t1     full join table2 t2 on t1.name = t2.name     full join table3 t3 on t1.name = t3.name or t3.name = t2.name     , t1.name = 'joe' , t2.name = 'joe' , t3.name = 'joe' 

now problem not @ .net tell me after putting query in db in sqlprocedure section.. how should call output frontend when search query processed.

i hope helps.. here sqlfiddle query :

http://sqlfiddle.com/#!6/6f3ad/17

in aspx page add datalist

<table border="0" cellpadding="0" cellspacing="0">         <asp:datalist runat="server" id="gvdata">             <headertemplate>                 <tr>                     <th>                         columnname                     </th>                     <th>                         columnname                     </th>                     <th>                         columnname                     </th>                 </tr>             </headertemplate>             <itemtemplate>                 <tr>                     <td>                         <%# eval("table1").tostring()%>                     </td>                     <td>                         <%# eval("table2").tostring()%>                     </td>                     <td>                         <%# eval("table3").tostring()%>                     </td>                 </tr>             </itemtemplate>         </asp:datalist> </table> 

and aspx.cs add method

public void binddata() {     string strconnstring = configurationmanager.connectionstrings["applicationservices"].connectionstring;      sqlconnection con = new sqlconnection(strconnstring);      sqlcommand cmd = new sqlcommand();      cmd.commandtype = commandtype.storedprocedure;      cmd.commandtext = "getproduct";      cmd.connection = con;      con.open();      try     {         gvdata.datasource = cmd.executereader();          gvdata.databind();     }      catch (exception ex)     {         throw ex;     }          {         con.close();          con.dispose();     } } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -