Level II

Connect to SQL databse programmatically

I made  Add In that create data base connection

but trying to retrive the data using diffrent scripts / add in does not work

do i need to creata data base connection on every add in?

this is my connection add in script

New Window("USER ID and pass", <<Modal, Text Box("insert user ID"), variablebox1 = Text Edit Box(),Text Box("insert password"), variablebox2 = Text Edit Box(<<Password Style));
userID = variablebox1 <<get text ; 
pass = variablebox2 <<get text ;  

abc = Create Database Connection("DSN=DB;UID="||userID||";PWD="||pass||";MODE=SHARE;DBALIAS=DB;");

but whenever i try to use the abc connection from diffrent add in / script it doest find it

Name Unresolved: dbc in access or evaluation of 'dbc' , dbc

dt = Execute SQL(
dbc/*###*/, ...

Super User

Re: Connect to SQL databse programmatically

Sounds like a scoping problem.  Make the connection variable a global variable by prefacing it with "::".

::abc  = Create Database Connection( "DSN=DB;UID=" || userID || ";PWD=" || pass || ";MODE=SHARE;DBALIAS=DB;" );

Article Labels

    There are no labels assigned to this post.