Adding new column in exist table
I am working on visual studio 2010 Professional, i have table and i want to add new column and name the the column by get it from a form that contain texttbox, then i enter column name and then click on add button and then i would have a new column added to my exist table
Kunal VaishyaPosted May 28, 2012, 9:11 AM
Alter Table TableName Add FldName FieldType
Example
Alter Table Company Add ComapnyAddress VarChar(50)
Kunal VaishyaPosted May 28, 2012, 1:07 PM
sCon = "Connection String";
System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection (sCon);
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = " Alter Table Company Add ComapnyAddress VarChar(50) ";
cmd.Connection = cn;
cn.Open();
cmd.ExecuteNonQuery();
younis abdeljawwadPosted May 28, 2012, 10:20 AM