From: Dave Halliday Date: 2003-09-12T18:52:57+09:00 Subject: Re: DBI/ODBC question: how to create DB programmatically? Thanks Chris. That's what I was looking for. I never thought of using win32ole. In the meantime, I did manage to create an Access database using the undocumented add_dsn() method in the ODBC driver: drv = ODBC::Driver.new drv.name = "Microsoft Access Driver (*.mdb)" drv.attrs = {"CREATE_DB" => ".\\test.mdb General"} ODBC.add_dsn(drv) Cheers, Dave "Chris Morris" wrote in message news:3F60CFF0.8000805@clabs.org... > Dave Halliday wrote: > > >Hi, > > > >I've been trying to figure out how to use ODBC with DBI. So far, I have > >created a DSN for an existing DB and managed to read tables, update them, > >etc, but I'd like to be able to create a new DB from scratch > >programmatically (i.e. without any manual steps to create a DSN and add a > >database). > > > Access: > > cat = WIN32OLE.new('ADOX.Catalog') > cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data > Source=#{@out_mdb_fn}" > > SQL Server: > > db = WIN32OLE.new("ADODB.Connection") > db.Open "Provider=SQLOLEDB;Data Source=myserver;Database=master;..." > db.execute("CREATE DATABASE mydb") > > -- > > Chris > http://clabs.org/blogki > > >