F
furface44
Guest
DataTable dt = new DataTable();
dt.Columns.Add("Modnam");
dt.Columns.Add("Optnam");
dt.Columns.Add("Cost");
SqlConnection LTConn = new SqlConnection(connect); // connect is my connection string to the database
LTConn.Open();
SqlCommand LTCmd = new SqlCommand();
LTCmd.Connection = LTConn;
LTCmd.CommandType = CommandType.StoredProcedure;
LTCmd.Parameters.AddWithValue("@modelname", modelname);
LTCmd.CommandText = "ArmyOptions";
SqlDataAdapter getDapt = new SqlDataAdapter();
getDapt.SelectCommand = new SqlCommand(LTCmd.CommandText, LTConn);
getDapt.SelectCommand.CommandType = CommandType.StoredProcedure;
getDapt.Fill(dt);
LTConn.Close();
foreach (DataRow dr in dt.Rows)
{
DataGridViewRow row = (DataGridViewRow)dgvOptions.Rows[0].Clone();
row.Cells[0].Value = dr["Modnam"].ToString();
row.Cells[1].Value = dr["Optnam"].ToString();
row.Cells[2].Value = dr["Cost"].ToString();
dgvOptions.Rows.Add(row);
}
Continue reading...
dt.Columns.Add("Modnam");
dt.Columns.Add("Optnam");
dt.Columns.Add("Cost");
SqlConnection LTConn = new SqlConnection(connect); // connect is my connection string to the database
LTConn.Open();
SqlCommand LTCmd = new SqlCommand();
LTCmd.Connection = LTConn;
LTCmd.CommandType = CommandType.StoredProcedure;
LTCmd.Parameters.AddWithValue("@modelname", modelname);
LTCmd.CommandText = "ArmyOptions";
SqlDataAdapter getDapt = new SqlDataAdapter();
getDapt.SelectCommand = new SqlCommand(LTCmd.CommandText, LTConn);
getDapt.SelectCommand.CommandType = CommandType.StoredProcedure;
getDapt.Fill(dt);
LTConn.Close();
foreach (DataRow dr in dt.Rows)
{
DataGridViewRow row = (DataGridViewRow)dgvOptions.Rows[0].Clone();
row.Cells[0].Value = dr["Modnam"].ToString();
row.Cells[1].Value = dr["Optnam"].ToString();
row.Cells[2].Value = dr["Cost"].ToString();
dgvOptions.Rows.Add(row);
}
Continue reading...