Witajcie, jak przy użyciu OleDb dodać do istniejącej bazy tabelę, albo skopiować atrybuty istniejącej dodając jednocześnie jedną kolumnę dodatkową.
Ja zw swojej strony napotkałem się na coś takiego, ale mało z tego rozumiem i nic mi to nie dało.
To create a table you first create a Catalog object, then a new Table object. You use the Append method of the Table object’s Columns collection to add field definitions (Column objects) to the Columns collection. Finally, you append the Table object to the Tables collection of the Catalog object. It is not necessary to use the Create method to create Column objects for the field definitions before you append them to the Columns collection. The Append method can be used both to create and to append the Column object. The following example uses these objects to create a Contacts table in the database specified in the strDBPath argument.
Sub CreateTable(strDBPath As String)
Dim catDB As ADOX.Catalog
Dim tblNew As ADOX.TableSet catDB = New ADOX.Catalog
' Open the catalog.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strDBPathSet tblNew = New ADOX.Table
' Create a new Table object.
With tblNew
.Name = "Contacts"
' Create fields and append them to the
' Columns collection of the new Table object.
With .Columns
.Append "FirstName", adVarWChar
.Append "LastName", adVarWChar
.Append "Phone", adVarWChar
.Append "Notes", adLongVarWChar
End With
End With' Add the new Table to the Tables collection of the database.
catDB.Tables.Append tblNewSet catDB = Nothing
End Sub
W tej chwili mam to tak:
private void test()
{
OleDbConnection accesConn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+sciezkaBazy+";Persist Security Info=True");
accesConn.Open();
OleDbCommand tworz = new OleDbCommand("CREATE TABLE mytable (int C(10), char C(10));",accesConn);
tworz.ExecuteNonQuery();
if (accesConn != null)
accesConn.Close();
}
Oczywiście będę kombinował, ale może ktoś pomoże. Plz Help.