Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Connecting to external database from dxl script
Topic Summary:
Created On: 2-Jan-2006 18:37
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 2-Jan-2006 18:37
User is offline View Users Profile Print this message


Michael Klaene

Posts: 4
Joined: 5-May-2005

I've seen a couple of threads on this topic but they were incomplete. Is it fairly easy to access an external database, say Oracle or Access, from a dxl script? Anyone have any examples? A project I'm looking at needs to read from a data warehouse and create modules, attritbutes, etc. in DOORS based upon the data. I'm just trying to think of the best ways to do this. I guess I could connect to DOORS via a stored proc or something but am thinking it might be easier to wrap everything in dxl if I can work with the database there. Any ideas/suggestions are appreciated. Thanks, Mike
Report this to a Moderator Report this to a Moderator
 2-Jan-2006 21:17
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Michael,

spontaneous I have three ideas for solving your problem :
1) export existing DB into CVS and use default DOORS inport function --> a DXL script could then create any needed links hierarchy etc. from this data
2) use OLE automation to run DXL code (may be in Excel or Access)
3) use DOORs DXL OLE automation to access ODBC driver in Excel, Access....

May be later, I will need soming like that too, but for now I haven't enough time to program it, sorry.

Greetings
Reik Schröder

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 2-Jan-2006 21:48
User is offline View Users Profile Print this message


Michael Klaene

Posts: 4
Joined: 5-May-2005

Okay. Thanks for the suggestions and ideas.
Report this to a Moderator Report this to a Moderator
 2-Jan-2006 22:05
User is offline View Users Profile Print this message


Michael Klaene

Posts: 4
Joined: 5-May-2005

By the way, if anyone has any experience doing as Reik describes in #3 (use DOORs DXL OLE automation to access ODBC driver in Excel, Access), I would love to see a simple example. Thanks, Mike
Report this to a Moderator Report this to a Moderator
 3-Jan-2006 10:38
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Michael,
I've only used OLE automation export/import to/from Excel or Word, but not dealed with ODBC.

I would suggest to you to try first to access a dabase from integreted VBA (in Access or Excel). Sometimes it is usefull to record a macro and have a look into generated VB code.

If you have created a function in VBA, wich does, what you need, you can try to convert it into DOORS. An example of using OLE in DOORs is given in Telelogic\DOORS 7.1\lib\dxl\standard\export\office\excel.dxl

It is very much esier, if you try it before in VBA, because there you have debuger, help file, etc.

Good Luck!

Greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 3-Jan-2006 10:52
User is offline View Users Profile Print this message


Karen Hidalgo

Posts: 55
Joined: 4-Nov-2003

Not sure if this is what you are looking for, but I found this piece of DXL code that connects to a MSAccess database from DOORS (have not tried it myself yet). I believe I found this code posted in this forum some time ago. It may help you get started.

OleAutoObj oConn
OleAutoObj oRst
string vCS
int records = 0
int state = 0
int iRec = 0
string result = ""
string sConn = ""
string sValue1 = ""
string sValue2 = ""
OleAutoArgs objArgBlock1 = create
OleAutoArgs objArgBlock2 = create

vCS = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\DOORS.MDB" // path !!!
oConn = oleCreateAutoObject("adodb.connection")
oRst = oleCreateAutoObject("adodb.recordset")
oFields = oleCreateAutoObject("adodb.fields")
oField1 = oleCreateAutoObject("adodb.field")
oField2 = oleCreateAutoObject("adodb.field")

/*
Connect to the database and open it
*/

olePut( oConn , "ConnectionString" , vCS )
oleMethod( oConn , "Open")
oleGet( oConn , "ConnectionString" , sConn )

/*
Attempt to open the record set
*/

olePut( oRst , "Source" , "Select * from DOORS" ) // SQL statement
olePut( oRst , "CursorType" , 0 ) // 0 = forward cursor only
olePut( oRst , "CursorLocation" , 3 ) // client cursor
olePut( oRst , "Mode" , 1 ) // locking = readonly
olePut( oRst , "ActiveConnection" , oConn ) // set connection
oleMethod( oRst , "Open" )

oleGet( oRst , "State" , state )
if ( state == 1 ) print "Connection opened...\n";

oleGet( oRst , "RecordCount" , records )
print "Query returned " records " records\n";
oleMethod( oRst , "MoveFirst")

oleGet( oRst, "Fields", oFields)

put(objArgBlock1, "field01") // first field name
oleMethod(oFields, "Item", objArgBlock1, oField1)

put(objArgBlock2, "field02") // second field name
oleMethod(oFields, "Item", objArgBlock2, oField2)


for (x=1; x <= records; x+=1) {
sValue1 = " "
sValue2 = " "

oleGet(oField1, "Value", sValue1 )
oleGet(oField2, "Value", sValue2 )

oleMethod( oRst , "MoveNext" )
print x "\t" iRec "\t" sValue1 " " sValue2 "\n"

}

delete(objArgBlock1)
delete(objArgBlock2)

oleMethod(oRst, "close"); // Close the record set
oleMethod(oConn, "close"); // Close the connection

-------------------------
Karen Hidalgo<BR>Northrop Grumman - TASC<BR>karen.hidalgo@ngc.com
Report this to a Moderator Report this to a Moderator
 3-Jan-2006 17:24
User is offline View Users Profile Print this message


Michael Klaene

Posts: 4
Joined: 5-May-2005

Thanks!  Couldn't find the code in the forum.  I was half way there already, but that bit of code worked perfectly, just change the connection string, the query, and field names and you're done.

Mike
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.