SqlConnection con = new SqlConnection(cnString1);//connection to the your database SqlCommand cmd = new SqlCommand("fetchUUSLaminateName", con);//create a SQL command object by passing name of the stored procedure and database connection cmd.CommandType = CommandType.StoredProcedure;//set command object command type to stored procedure type SqlDataAdapter adp = new SqlDataAdapter(cmd);//create SQL data adapter with command object DataTable dt = new DataTable();//create a data table to hold result of the command //DataGridViewComboBoxColumn dgvcmb = new DataGridViewComboBoxColumn(); if (con.State == ConnectionState.Closed)//check whether connection to database is close or not con.Open();//if connection is close then only open the connection adp.Fill(dt);//data table fill with data by calling the fill method of data adapter object if (dt.Rows.Count > 0)//check whether data table contain any row or not { LamiName.DataSource = dt; LamiName.ValueMember = "UUSLaminateName"; LamiName.DisplayMember = "UUSLaminateName"; dgvUUSKreationPriceCalculator.DataSource = dt; if (con.State == ConnectionState.Open) con.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)