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: DXL and Windows ADO database ?
Topic Summary:
Created On: 3-Feb-2003 17:34
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.
Answer This question was answered by Chris Welch, on Thursday, February 6, 2003 5:28 PM

Answer:
Missed it by thaaaatttt ('.') much!

For those of you looking into this here is a working sample (you'll need the attached Access database and the ODBC drivers).
 3-Feb-2003 17:34
User is offline View Users Profile Print this message


Chris Welch

Posts: 9
Joined: 27-Jan-2003

Has anybody been able to get DOORS to use Windows ADO objects to access an ODBC database ? I've got one that is "nearly there" but oleGet and oleMethod seem to be lacking. The documentation for this is typical of DOORS and is sorely lacking. I'm hoping to hear back shortly from Support but figured I'd increase my chances.

In case you are curious about what/how I'm doing this here is an example of the code that uses an Access database. This is a tweak of some very basic VBScript to use DXL and opens the db, opens a recordset and then accesses it. I can use the "GetString" method and parse the data but it shouldn't need to be done.


//* code starts here
OleAutoObj oConn
OleAutoObj oRst
string vCS
int records = 0
int state = 0
int iRec = 0
int lEOF = -1
string result = ""
string sConn = ""
string myText = ""
string sField = ""


OleAutoArgs autoArgs = create

vCS = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\DOORS.MDB"
oConn = oleCreateAutoObject("adodb.connection")
oRst = oleCreateAutoObject("adodb.recordset")


/*
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" ) // query
olePut( oRst , "CursorType" , 1 ) // 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 )
infoBox "State = " state " "; // 1 = opened recordset !

oleGet( oRst , "RecordCount" , records )
infoBox "#records = " records "..."; // how many records were returned from the query

oleMethod( oRst , "MoveLast") // go to the first record
oleGet( oRst, "AbsolutePosition" , iRec ) // what is the record # ?
infoBox "Current record = " iRec "" ;


//oleMethod( oRst , "MoveLast")
//oleMethod( oRst , "AddNew" ) // this -would- be the syntax to add
// olePut( oRst , "fields(\"field01\")" , "bubba") // and save a record but it doesn't
// olePut( oRst , "fields(\"field02\")" , "raul" ) // work either!
//oleMethod( oRst , "Update" )


sField = "Fields(\"field01\")" // this should be the syntax to get a field's value!

oleGet( oRst , sField , myText )
infoBox sField " = " myText ; // in VB it would be oRst("LastName")


oleMethod( oRst , "MoveFirst") // move back to first to get all records!
oleGet( oRst , "getstring" , myText ) //proof that this is getting the data!
infoBox "Here is my proof:\n" myText "" ; // SO, WTF OVER ?!?

Stream out = write "c:\\proof.txt" // write the data to a temporary file!
out << myText; //
close(out); //

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

//* code ends here here
Report this to a Moderator Report this to a Moderator
 6-Feb-2003 14:29
User is offline View Users Profile Print this message


Judith Underwood

Posts: 35
Joined: 25-Sep-2002

I know absolutely nothing about ADO objects, but my guess would be that the problem is the syntax:

sField = "Fields(\"field01\")" // this should be the syntax to get a field's value!
oleGet( oRst , sField , myText )

This is getting the Fields collection and then getting an element of the collection in one big step. Try breaking it down to two or three steps -- something like

OleAutoObj oleFields
oleGet( oRst, "Fields", oleFields)

to get the fields collection as an object in itself, and then

OleAutoArgs objArgBlock = null
OleAutoObj oleField

clear objArgBlock
put(objArgBlock, "field01")
oleMethod(oleFields, "Item", objArgBlock, oleField) // get the field object
oleGet(oleField, "Value", myText) // get the value for the field

Good luck,
Judith
Report this to a Moderator Report this to a Moderator
 6-Feb-2003 17:28
User is offline View Users Profile Print this message


Chris Welch

Posts: 9
Joined: 27-Jan-2003

Answer Answer
Missed it by thaaaatttt ('.') much!

For those of you looking into this here is a working sample (you'll need the attached Access database and the ODBC drivers).


Edited: 6-Feb-2003 at 17:31 by Chris Welch
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 0 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 0 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.