Column Conversion via ADOX?

X

xenophon

I want to use ADOX to change a VarChar (aka Access Text) column to a
DateTime. How do I do that via code (VB, C#, etc)?

Thanks.
 
B

Brendan Reynolds

You don't need ADOX for that, you can do it with ADODB ...

objConnection.Execute "ALTER TABLE tblTest ALTER COLUMN TestText Date"

.... where objConnection is your ADODB.Connection object

Or, as you mention C#, you can use ADO.NET ...

using System;
namespace TestAlterColumn
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ @"Data Source=\\ServerName\ShareName\FileName.mdb;"
+ "Persist Security Info=False";
string commandText = "ALTER TABLE tblTest ALTER COLUMN TestText Date";
System.Data.OleDb.OleDbConnection connection
= new System.Data.OleDb.OleDbConnection(connectionString);
System.Data.OleDb.OleDbCommand command
= new System.Data.OleDb.OleDbCommand(commandText, connection);
try
{
connection.Open();
command.ExecuteNonQuery();
}
catch (System.Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadLine();
}
finally
{
connection.Close();
}
}
}
}
 
C

carla abreu

xenophon said:
I want to use ADOX to change a VarChar (aka Access Text) column to a
DateTime. How do I do that via code (VB, C#, etc)?

Thanks.



merry christmas and happy new year
and nice to meet you...
goodbye
 
G

Guest

Je te remercie pour tes voeux et je te souhaite également une bonne et
heureuse année 2006.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top