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

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)
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.