Visual LISP, AutoLISP and General Customization
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
*vianello, davide
mysql
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
239 Views, 3 Replies
12-12-2001 06:39 PM
hi
Has anyone tried to connect with MySQL database?
Any help or suggestion is appreciated.
thank you in advance
Davide
Has anyone tried to connect with MySQL database?
Any help or suggestion is appreciated.
thank you in advance
Davide
*Young, Darren J.
Re: mysql
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-12-2001 10:44 PM in reply to:
*vianello, davide
In article <8E738CA5E6BAD90DD0B6F6A71FF9350B@in.WebX.maYIadrT aRb>,
jmpdvi@tin.it says...
> hi
>
> Has anyone tried to connect with MySQL database?
> Any help or suggestion is appreciated.
Try the connectivity group. There's a couple folks there (Jn Fleming &
Scott McFarlane) that are very good with databases.
--
Sincerely,
Darren J. Young
Minnesota CADWorks, Inc.
P.O. Box 7293
Saint Cloud, Minnesota 56302-7293
Phone: (320) 654-9053
WWW: http://www.mcwi.com
jmpdvi@tin.it says...
> hi
>
> Has anyone tried to connect with MySQL database?
> Any help or suggestion is appreciated.
Try the connectivity group. There's a couple folks there (Jn Fleming &
Scott McFarlane) that are very good with databases.
--
Sincerely,
Darren J. Young
Minnesota CADWorks, Inc.
P.O. Box 7293
Saint Cloud, Minnesota 56302-7293
Phone: (320) 654-9053
WWW: http://www.mcwi.com
Re: mysql
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-28-2006 11:21 AM in reply to:
*vianello, davide
I found a way to connect to a mysql database with vlisp. first i installed the ODBC mysql driver from the mysql website. then i created a vlisp command to connect to the dll and run a query. here's an example of the code i wrote.
(vl-load-com)
(defun mysqlQuery (sQuery / $acad dbConn dbConnString dbResult field item)
;connect to autocad application object
(setq $acad (vlax-get-acad-object))
;connect to the mysql dll object
(setq dbConn (vla-GetInterfaceObject $acad "ADODB.Connection"))
;open the mysql database
(setq dbConnString (strcat "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;"
"DATABASE=mydb; UID=myid; PWD=mypassword; OPTION=3")
)
(vlax-invoke dbConn "Open" dbConnString)
;run a query on the database
(setq dbResult (vlax-invoke dbConn "Execute" sQuery))
;find the field, item, and value of the first object in the recordset
(setq field (vlax-get-property dbResult "Fields"))
(setq item (vlax-get-property field "Item" 0))
(setq value (vlax-get-property item "Value"))
;release the autocad application and mysql object
(vlax-invoke-method dbConn "Close")
(vlax-release-object dbConn)
(vlax-release-object $acad)
;prompt the result
(prompt (vlax-variant-value value))
(princ)
)
to run the command i have to send an sql query.
(mysqlQuery "SELECT name FROM staff WHERE name LIKE '%Smith%'")
(vl-load-com)
(defun mysqlQuery (sQuery / $acad dbConn dbConnString dbResult field item)
;connect to autocad application object
(setq $acad (vlax-get-acad-object))
;connect to the mysql dll object
(setq dbConn (vla-GetInterfaceObject $acad "ADODB.Connection"))
;open the mysql database
(setq dbConnString (strcat "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;"
"DATABASE=mydb; UID=myid; PWD=mypassword; OPTION=3")
)
(vlax-invoke dbConn "Open" dbConnString)
;run a query on the database
(setq dbResult (vlax-invoke dbConn "Execute" sQuery))
;find the field, item, and value of the first object in the recordset
(setq field (vlax-get-property dbResult "Fields"))
(setq item (vlax-get-property field "Item" 0))
(setq value (vlax-get-property item "Value"))
;release the autocad application and mysql object
(vlax-invoke-method dbConn "Close")
(vlax-release-object dbConn)
(vlax-release-object $acad)
;prompt the result
(prompt (vlax-variant-value value))
(princ)
)
to run the command i have to send an sql query.
(mysqlQuery "SELECT name FROM staff WHERE name LIKE '%Smith%'")
Re: mysql
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-08-2012 10:17 PM in reply to:
*vianello, davide
It works!
However, the data returned is only for one row. Could you show how to get multiple rows (or records)?
Thanks in advance!
