ASE, SQL, OLE, ADE

ASE, SQL, OLE, ADE

Reply
*Wang, Weslley X
Message 1 of 4 (132 Views)

How I can know if I connect to database in LISP

132 Views, 3 Replies
01-12-2000 11:17 AM
Hello:
I am working with a Map Util project. I try to make a Link Path.
before I do it, I have to check if the same name Link Path existed. If
there are no same name Link Path existed, I will create one. when I
tested my code, I found it crashed a lot. because there so many case I
can not determine:
a drawing with database connected or not, a drawing with database
attached or not, If I connect a database and then disconnect it, the
condition is not like one before I connect the database.

Here is my code:
;;
(defun connect (table keyfield lpn)
(cond (trace_functions (princ "\nSubroutine: Connect")))
(setq connectionok nil)
(setvar "cmddia" 0)
(princ "\nVerifying database connection to the ")
(princ table)
(princ " table. Please wait.")
;; The following segment was added on August 16 to CONFIRM connection
to a database table.
(if (member (list table keyfield lpn) connectionlist)
(progn ;; If the table we are searching for is already in the list
of connected tables
(setq sqlstr (strcat "SELECT * FROM " odbcschema "." table))
(if (null session)
(setq session (asi_connect odbcname username passwrod))
) ;_ end of if
(setq statement (asi_prepare session sqlstr))
(if statement ;If the statement creation is NOT valid, go through
the connection process.
(progn (setq connectionok T) (asi_deallocstm statement))
) ;_ end of if
) ;_ end of progn
) ;_ end of if
;;
;;
(if (not connectionok)
(progn
;;
(setq dostatus (ase_dostatus (ase_lppath lpn))) ;Set the database
object status
(if (= dostatus 18) ;If the status is not confirmed...
(progn (command "aseadmin" "environment" odbcname "exit")
(setq dostatus (ase_dostatus (ase_lppath lpn))) ;Update the
database object status
(if (= dostatus 18) ;If the status is still unconfirmed...
(progn (princ "\nPerforming full connection to environment ")
(princ odbcname)
(command "aseadmin" "environment" odbcname "options" "connect"
username password "exit" "exit")
) ;_ end of progn
) ;_ end of
) ;_ end of progn
) ;_ end of
;;
;;
(cond ;;
((and (= (substr (ase_docurrent) 1 (strlen odbcname)) odbcname)
(null dostatus))
(princ (strcat "\nCreating Link Path Name " (strcase lpn)))
(command "aseadmin" "catalog" "CAD" "schema" odbcschema
"table" table "options"
"link-paths" "new" keyfield "" lpn "set" lpn
"exit" "exit" "exit"
) ;_ end of command
)
;;
((null dostatus)
(princ (strcat "\nCreating Link Path Name " (strcase lpn)))
(command "aseadmin" "environment" odbcname "options"
"connect" username password
"" "catalog" "CAD" "schema" odbcschema "table"
table "options"
"link-paths" "new" keyfield "" lpn "set"
lpn
"exit" "exit" "exit"
) ;_ end of command
)
;;
((= dostatus 10)
(princ (strcat "\nCreating Link Path Name " (strcase lpn)))
(command "aseadmin" "environment" odbcname "options"
"connect" username password
"exit" "Table" table "options" "link-paths"
"n" keyfield
"" lpn "exit" "exit" "exit"
) ;_ end of command
)
;;
((< dostatus 14)
(princ (strcat "\nCreating Link Path Name " (strcase lpn)))
(command "aseadmin" "Table" table "options" "link-paths" "n"
keyfield "" lpn "exit" "exit" "exit")
)
) ;_ end of cond
) ;_ end of progn
;;
(progn ;;
(setq dostatus (ase_dostatus (ase_lppath lpn)))
;;
(if (and (= (substr (ase_docurrent) 1 (strlen odbcname)) odbcname)
(null dostatus))
(progn ;;
(princ (strcat "\nCreating Link Path Name " (strcase lpn)))
(command "aseadmin" "catalog" "CAD" "schema" odbcschema
"table" table "options"
"link-paths" "new" keyfield "" lpn "set"
lpn
"exit" "exit" "exit"
) ;_ end of command
) ;_ end of progn
) ;_ end of if
) ;_ end of progn
) ;_ end of
;;
(if (null session)
(setq session (asi_connect odbcname username password)) ;Connect to
the ODBC connection.
) ;_ end of if
;;
(if (not (member (list table keyfield lpn) connectionlist))
(setq connectionlist (append connectionlist (list (list table
keyfield lpn))))
) ;_ end of
;;
(setvar "cmddia" 1)
(princ)
) ;_ end of function CONNECT
;; end of code

If you can help, thanks a lot

Weslley X Wang
I am working on Map 3, Windows NT 4. SP3 with Pentium Pro 200, 128 MB
memory,
*Fleming, Jon
Message 2 of 4 (132 Views)

Re: How I can know if I connect to database in LISP

01-12-2000 02:37 PM in reply to: *Wang, Weslley X
I don't have much experience with LPNs and Displayable Attributes.
However, you might find DBL202.ZIP from http://www.cadalog.com useful (in
the portions of your program where you execute SQL statements directly).

jrf
Member of the Autodesk Discussion Forum Moderator Program

In article <387CD32C.9FECD3BB@autodes.com>, Weslley X Wang wrote:
> Hello:
> I am working with a Map Util project. I try to make a Link Path.
> before I do it, I have to check if the same name Link Path existed. If
> there are no same name Link Path existed, I will create one. when I
> tested my code, I found it crashed a lot. because there so many case I
> can not determine:
> a drawing with database connected or not, a drawing with database
> attached or not, If I connect a database and then disconnect it, the
> condition is not like one before I connect the database.
*DS
Message 3 of 4 (132 Views)

Re:

02-10-2000 07:43 PM in reply to: *Wang, Weslley X
Jon,

Once again, that web site is still showing a message that they are down with
hardware failures (2/10/00). Anyway you could post that file here somehow?
Maybe in teh Customer Files section?

Thanks! Dave Stein

"Jon Fleming" wrote in message
news:VA.00000b96.04ef44f9@fleming-group.com...
> ...you might find DBL202.ZIP from http://www.cadalog.com useful
*Fleming, Jon
Message 4 of 4 (132 Views)

Re:

02-11-2000 04:27 AM in reply to: *Wang, Weslley X
OK.

jrf
Member of the Autodesk Discussion Forum Moderator Program

In article <8800bg$seu2@adesknews2.autodesk.com>, Ds wrote:
> Jon,
>
> Once again, that web site is still showing a message that they are down with
> hardware failures (2/10/00). Anyway you could post that file here somehow?
> Maybe in teh Customer Files section?
>
> Thanks! Dave Stein
>
> "Jon Fleming" wrote in message
> news:VA.00000b96.04ef44f9@fleming-group.com...
> > ...you might find DBL202.ZIP from http://www.cadalog.com useful
>
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.