Ask a Question related to Ruby, Design and Development.
-
Dave Halliday #1
DBI/ODBC question: how to create DB programmatically?
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).
Is there a way to do this from the DBI interface? I've found a few VB
examples and dug around in the ODBC source code, but I can't quite make the
leap from the VB code to the DBI API.
I'm using Windows XP and Ruby 1.8.0.
Thanks,
Dave Halliday
Dave Halliday Guest
-
create ODBC connection in CF?
Is there a way to create ODBC DSNs via code? Even if I have to execute something in another language... -
[HOW TO DO] Programmatically create photograms?
LOT for you reply. Now I have the problem to refer to generated movieClip (how is it possible by name?) to move then and generate "trailer titles"... -
Programmatically create buttons from user control
Hello guys, I have an application which is built upon several user controls. That is, I have a default template (default.aspx) that I load a user... -
create treeview control programmatically
see http://support.microsoft.com/default.aspx?scid=KB;EN-US;210125 "William Grigg" <wgrigg@draper.com> wrote in message... -
Programmatically create HTTP post
Thanks for the reply, Bob. Unfortunately this won't work for me. The external web site is expecting an HTTP POST document. My .asp server page... -
Michael Neumann #2
Re: DBI/ODBC question: how to create DB programmatically?
On Thu, Sep 11, 2003 at 11:51:08AM +0900, Dave Halliday wrote:
There's no special command to create databases with DBI/ODBC. Usually,> 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).
you can create a database by issuing the "CREATE DATABASE ..." SQL
statement, but this will probably not create a DSN for you.
Everything what you can do in VB should be possible in Ruby by using the> Is there a way to do this from the DBI interface? I've found a few VB
> examples and dug around in the ODBC source code, but I can't quite make the
> leap from the VB code to the DBI API.
win32ole module (this is how the ADO database driver is implemented).
Have a look at the ADO database driver (part of DBI in directory> I'm using Windows XP and Ruby 1.8.0.
lib/dbd_ado). Look how it's using the ADODB.Connection COM object, and
try to translate the VB example into Ruby.
Hope this helps.
Regards,
Michael
Michael Neumann Guest
-
Chris Morris #3
Re: DBI/ODBC question: how to create DB programmatically?
Dave Halliday wrote:
Access:>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).
>
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
[url]http://clabs.org/blogki[/url]
Chris Morris Guest
-
Dave Halliday #4
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" <chrismo@clabs.org> wrote in message
news:3F60CFF0.8000805@clabs.org...> Dave Halliday wrote:
>> Access:> >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).
> >
>
> 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
> [url]http://clabs.org/blogki[/url]
>
>
>
Dave Halliday Guest



Reply With Quote

