Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First Create A connection Class in App_code folder and dont forget to set database path</p> <pre><code>using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; /// &lt;summary&gt; /// Summary description for Connection /// &lt;/summary&gt; public class Connection { SqlConnection con = new SqlConnection(); SqlDataAdapter ad; SqlCommand cmd; SqlDataReader rd; public Connection() { // Set Your Database Path Here from C:\user onwords con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\SIROI.COM\Documents\Visual Studio 2008\WebSites\WebSite14\App_Data\ASPNETDB.MDF;Integrated Security=True;User Instance=True"; } public DataSet filldata(DataSet ds, string query, string tbname) { try { con.Open(); ad = new SqlDataAdapter(query, con); ad.Fill(ds, tbname); } catch (SqlException ex) { } finally { con.Close(); } return ds; } public bool ExecuteQuery(string query) { bool flag = false; try { con.Open(); cmd = new SqlCommand(query, con); int a = cmd.ExecuteNonQuery(); if (a &gt; 0) { flag = true; } } catch(Exception ex) { } finally { con.Close(); } return flag; } public SqlDataReader ExecuteReader(string query) { try { con.Open(); cmd = new SqlCommand(query, con); rd = cmd.ExecuteReader(); } catch (Exception ex) { } return rd; } } </code></pre> <p>Now create data source by calling connection</p> <pre><code>&lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ASPNETDBConnectionString1 %&gt;" SelectCommand="Your * SQL Query"&gt; &lt;SelectParameters&gt; &lt;asp:QueryStringParameter Name="Your param" QueryStringField="Your Field" Type="String" /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre> <p>Now at last Create a Label and set field name to retrive in Bind Function</p> <pre><code>&lt;asp:Label ID="Label6" runat="server" Text='&lt;%# Bind("your Field") %&gt;'&gt;&lt;/asp:Label&gt; </code></pre> <blockquote> <p>Regards <a href="http://www.siroi.com" rel="nofollow">http://www.siroi.com</a> Dont Forget to like us on Facebook <a href="http://www.facebook.com/siroi.india" rel="nofollow">http://www.facebook.com/siroi.india</a></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload