c# code for get datas directlly from datatable to textbox events in .net



This is A C# Practice code:
        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 dataentry
        {
            public partial class datatotextbox : Form
            {
                SqlConnection abcdata = new SqlConnection("Data Source=.;Initial Catalog=DATAENTRY;Integrated Security=True;Pooling=False");
                public datatotextbox()
                {
                    InitializeComponent();
                }

                private void button9_Click(object sender, EventArgs e)
                {
                    SqlDataAdapter asdf = new SqlDataAdapter("select * from REGISTER where id ='" + textBox1.Text + "' ", abcdata);
                    DataTable ss = new DataTable();
                    asdf.Fill(ss);
                    textBox1.Text = ss.Rows[0][0].ToString();
                    textBox2.Text = ss.Rows[0][1].ToString();
                    comboBox1.Text = ss.Rows[0][2].ToString();
                    comboBox2.Text = ss.Rows[0][6].ToString();
                    textBox3.Text = ss.Rows[0][3].ToString();
                    textBox4.Text = ss.Rows[0][4].ToString();
                    textBox5.Text = ss.Rows[0][5].ToString();
                }
            }
        }


Video For Result:



Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Facebook Comment