¤ Paul, thank you for such a prompt response. Firstly, here's the code in C#:
¤
¤ ADOX.Catalog cat = new ADOX.Catalog();
¤ ADODB.Connection ADOconn = new ADODB.Connection();
¤ ADOconn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Jet OLEDB:Engine Type=5", "admin", "", 0);
¤ cat.ActiveConnection = ADOconn;
¤ cat.Tables["tablename"].Columns["oldcolname"].Name = "newcolname";
¤ ADOconn.Close();
¤ cat.ActiveConnection = null;
¤
¤ The thing is the Connection.Open has really four parameters here, intellisense tooltip says this:
¤
¤ "void _Connection.Open(string ConnectionString, string UserID, string Password, int Options)"
Just specify the connection string (first parameter). All the other arguments are optional if you
have a valid connection string.
¤
¤ No overloads, just this one with four parameters. Also, Catalog.ActiveConnection does not contain Close() here. That's why I had to
¤ close the connection directly through ADODB.Connection.
¤
Yes, your approach is correct.
¤ As for the question 1: since I could successfully build the solution a few moments later I was able to check how the above-mentioned
¤ code works. Everything was fine and no table had to be added into the Catalog. The zero supplied as Options is probably OK. Anyway,
¤ I will google it once more and hopefully find some information about this parameter.
¤
¤ Question 2: I've noticed two DLLs appeared in the bin folder with compiled solution. These DLLs are Interop.ADODB.dll and
¤ Interop.ADOX.dll. Correct question would probably be: Do I have to copy these two DLLs to the folder with my application everywhere
¤ I install it? Isn't there a way to "embed" them into the compiled EXE? In case I copied the application to some folder without those
¤ two files and run it, everything was fine, except when I tried to rename some column an error message saying "... component
¤ Interop.ADOX.dll <version info> could not be loaded." appeared and (obviously) column was not renamed.
¤
Just distribute the interop files with your application assembly (typically in the \bin folder). Yes
they are required.
¤ I'm sorry for my English, it probably makes the text much more confusing.
Your English is perfectly understandable. I just needed a bit more information.
Paul
~~~~
Microsoft MVP (Visual Basic)