0

Hi all
I am developing a form which has a gridview... i am try to do is.. it has three columns... the first two columns are for display purposr. The third column is a combobox column which displays different value for different rows.. it is fatched from database.. i am trying to do this but could not succed.... i dont how to load value from database to a gridview column... can any one please give a idea on this,,,

thanks
vince

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by lianpiau
0

Hi all
I am developing a form which has a gridview... i am try to do is.. it has three columns... the first two columns are for display purposr. The third column is a combobox column which displays different value for different rows.. it is fatched from database.. i am trying to do this but could not succed.... i dont how to load value from database to a gridview column... can any one please give a idea on this,,,

thanks
vince

load database data display in datagridview

private void OT_Load(object sender, EventArgs e)
        {
            Loads();
        }

private void Loads()
        {
            ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
            string name = conSettings.ProviderName;
            string providerName = conSettings.ProviderName;
            string ConnectionString = conSettings.ConnectionString;

            string sql = "SELECT * FROM OT ORDER BY OTDate DESC,Name";
            OleDbConnection connection = new OleDbConnection(ConnectionString);
            connection.Open();
            sCommand = new OleDbCommand(sql, connection);
            sAdapter = new OleDbDataAdapter(sCommand);
            sBuilder = new OleDbCommandBuilder(sAdapter);
            sDs = new DataSet();
            sAdapter.Fill(sDs, "OT");
            sTable = sDs.Tables["OT"];
            connection.Close();
            dataGridView1.DataSource = sDs.Tables["OT"];
            dataGridView1.ReadOnly = true;
            save_btn.Enabled = false;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            lblMessage.Text = "Display All Data";
            dtpDate.Value = System.DateTime.Today;
        }

u can use inner join to display another column from database

SELECT     PDC_FG.PONO, PDC_FG.DeliveryDate, PDC_FG.Customer, Customer.[Zone]
FROM         (PDC_FG INNER JOIN
                      Customer ON PDC_FG.Customer = Customer.Cust)
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.