hi .all
can i add new column in data table through gridview when form load?is it possible? plz tell how is it possible .my code is paste bellow.
private void Form3_Load(object sender, EventArgs e)
{
cn = new SqlConnection("data source=server2;database=costing1;user id=sa;password=sa");
da = new SqlDataAdapter("select *from Itemmaster", cn);
DataTable dt = new DataTable();
dt.Columns.Add("column005", typeof(int));
ds = new DataSet();
da.Fill(ds, "Itemmaster");
cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.StoredProcedure;
dataGridView1 .DataSource =ds .Tables ["Itemmaster"];
}
Loading
Lakhan PalPosted Sep 9, 2009, 7:26 AM
Try Out This:
May be this will work
private void Form3_Load(object sender, EventArgs e)
{
cn = new SqlConnection("data source=server2;database=costing1;user id=sa;password=sa");
da = new SqlDataAdapter("ALTER TABLE Itemmaster ADD column005 int;select * from Itemmaster", cn);
ds = new DataSet();
da.Fill(ds, "Itemmaster");
dataGridView1 .DataSource =ds .Tables ["Itemmaster"];
}