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

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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.