Book a Demo

Author Topic: API versus SQL Repository  (Read 4664 times)

TomVercauteren

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
API versus SQL Repository
« on: July 13, 2006, 07:44:48 am »
in stead of connecting to a file, I need to connect to SQLServer.  Anyone got an idea of how to do it?
I connect to a file using:
EARep = New Repository
EARep.OpenFile("C:\SomeRepository.eap")

But how do I fit the actual connectstring in there: Provider=sqloledb;Data Source=SERVER;Initial Catalog=EnterpriseArchitect;User Id=sa;Password=;
-------------------
(Reply does not work, so I edited my original post)

The solution below works fine, thx.
Only,... any request to the SQLServer doesn't get through, it seems...

This works fine:
       Dim EARep as New Repository
       EARep.OpenFile("C:\Localfile.eap")
       Dim EADia As Diagram
       EADia = EARep.GetDiagramByID(1)

I copied the EAP to the SQL, so it holds exacltly the same model.  Yet, this does not work:

       Dim EARep as New Repository
       EARep.OpenFile("MYSERVER --- DBType=1;Connect=Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=EnterpriseArchitect;Data Source=MYSERVER")        
       Dim EADia As Diagram
       EADia = EARep.GetDiagramByID(1)


« Last Edit: July 14, 2006, 02:54:47 am by TomVercauteren »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: API versus SQL Repository
« Reply #1 on: July 13, 2006, 09:18:32 am »
Hi Tom,

Siince I've stubled over this one twice (slow learner) myself I can certainly help.

EA requires that the "connection string" passed to the API be prefixed with a few characters. What you need is the 'user friendly' name you have given the model when you first created it, followed by a space, three dashes, and another space. You can get an example if you open a repository-based model in EA and then exit and restart EA. Look at the File menu and note how the model you references (probably as "2" in the list) is referenced; that is your connection string. Note that you want this string (or at least the prefix) exactly - punctuation, whitespace and capitalization all seem to count.

Once you've got this trick down you can adjust the balance of the parameters to suit your purposes, as you would any other OLEDB (or ODBC) application.

BTW, you can also open an EAP file this way. Simply use the appropriate provider and such in your connection string.

HTH, David
No, you can't have it!

colo

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: API versus SQL Repository
« Reply #2 on: November 09, 2006, 07:38:38 am »
Hi Midnight!
Could you bring me some example please?
I need open a SQL Server Repository from VB..
Thanks in advance..

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: API versus SQL Repository
« Reply #3 on: November 09, 2006, 07:48:43 am »
Colo,

I don't have an example handy just now and am trying to dash out the door.

Take a look at the File... menu from the 'human' UI to EA after you've opened and closed your SQL repository by hand. You'll see an entry - usually number 2 if you've just opened the repository - with the name you gave the repository, followed by " --- " (spaces included, but not the quotes) and then the ODBC or OLE connection string EA used to open the model.

When you open the repository from VB, use the string above (the whole thing including the name, punctuation, and connection string) instead of a file name. EA should open the repository and you'll be in business.

David
No, you can't have it!

alesliehughes

  • EA Administrator
  • EA User
  • *****
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: API versus SQL Repository
« Reply #4 on: November 19, 2006, 07:08:31 pm »
A trick you can use. Connect to you DMBS, and select "File --> Save Project As", enter a Filename.

Now to connect, all you have to do is.

Dim EARep as New Repository
EARep.OpenFile("filename.eap")


Alistair