using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Dbconnection
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        SqlDataAdapter da;
        SqlConnection con;
        DataSet ds1;

        private void Form1_Load(object sender, EventArgs e)
        {

            con = new SqlConnection("Data Source=hhh-pc\\sqlexpress;Initial Catalog=employees1;Integrated Security=True");
            con.Open();

            ds1 = new DataSet();
            string sql = "select * from tbl_employee";
            da = new SqlDataAdapter(sql, con);


            da.Fill(ds1, "Worker");
            Navigate_records();
            con.Close();

        }

        private void Navigate_records()
        {
            DataRow dRaw = ds1.Tables["workers"].Rows[0];
            textBox1.Text = dRaw.ItemArray.GetValue(1).ToString();
            textBox2.Text = dRaw.ItemArray.GetValue(2).ToString();
            textBox3.Text = dRaw.ItemArray.GetValue(3).ToString();
            textBox4.Text = dRaw.ItemArray.GetValue(4).ToString();

        }

    }
}

nothing is on the form. my database has data

nevermind. it worked. Had to change "worker" to "workers"

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.