0

Hello,

This is my first project using ASP.NET and I am very unfamiliar about it, basically I want to display records from a database in the user interface, I have created the user interface, and created a data sheet which has the table and queries listed, but how do I link it successfully to the text box on the User Interface?

I would really appreciate some assistance,

Thanks

4
Contributors
3
Replies
7
Views
7 Years
Discussion Span
Last Post by abdalla_92
0

Use the following code.. here my textbox id is TextBox1 and database name :records
Table name: data

using System.Collections;
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;

public partial class Default2 : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(@"Data Source=WINKC185045-MAB\SQLEXPRESS;Initial Catalog=Records;Integrated Security=True");
    protected void Page_Load(object sender, EventArgs e)
    {

        SqlDataAdapter da = new SqlDataAdapter("select * from data", con);
        DataSet ds = new DataSet();
        da.Fill(ds, "data");
        TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();





    }

   
}

Mark it as solved if you found solution.

0

Welcome rmc.

You should have to include a name of database and name of provider classes into your question. To fetch data from the database; use SELECT statement with where clause.

0

VB.NET:i want to select data from sql server 2005 DB table and displaying into text box that depends on combo box selection using VB.NET

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.