J
Jon Brunson
Is it possible to use a DataAdapter to fill a DataTable, change the
DataColumns of that DataTable (and maybe even it's name) and then commit
those changes to the database (in my case SQL Server 2000)?
Eg:
[VB.NET]
Dim dc As New SqlCommand("SELECT TOP 0 * FROM SomeTable",
SomeSqlConnection)
dc.CommandType = CommandType.Text
Dim da As New SqlDataAdapter(dc)
Dim dt As New DataTable
da.FillSchema(dt, SchemaType.Source)
dt.TableName = "NewTableName"
dt.Columns("SomeColumn").ColumnName = "NewName"
dt.Columns("AnotherColumn").DataType = GetType(String)
dt.Columns.Add("NewColumn", GetType(Integer))
da.Update(dt)
[C#]
SqlCommand dc = new SqlCommand("SELECT TOP 0 * FROM SomeTable",
SomeSqlConnection);
dc.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(dc);
DataTable dt = new DataTable();
da.FillSchema(dt, SchemaType.Source);
dt.TableName = "NewTableName";
dt.Columns["SomeColumn"].ColumnName = "NewName";
dt.Columns["AnotherColumn"].DataType = Type.GetType("System.String");
dt.Columns.Add("NewColumn", Type.GetType("System.Integer"));
da.Update(dt);
DataColumns of that DataTable (and maybe even it's name) and then commit
those changes to the database (in my case SQL Server 2000)?
Eg:
[VB.NET]
Dim dc As New SqlCommand("SELECT TOP 0 * FROM SomeTable",
SomeSqlConnection)
dc.CommandType = CommandType.Text
Dim da As New SqlDataAdapter(dc)
Dim dt As New DataTable
da.FillSchema(dt, SchemaType.Source)
dt.TableName = "NewTableName"
dt.Columns("SomeColumn").ColumnName = "NewName"
dt.Columns("AnotherColumn").DataType = GetType(String)
dt.Columns.Add("NewColumn", GetType(Integer))
da.Update(dt)
[C#]
SqlCommand dc = new SqlCommand("SELECT TOP 0 * FROM SomeTable",
SomeSqlConnection);
dc.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(dc);
DataTable dt = new DataTable();
da.FillSchema(dt, SchemaType.Source);
dt.TableName = "NewTableName";
dt.Columns["SomeColumn"].ColumnName = "NewName";
dt.Columns["AnotherColumn"].DataType = Type.GetType("System.String");
dt.Columns.Add("NewColumn", Type.GetType("System.Integer"));
da.Update(dt);