Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
fkeuroglian
Partner - Master
Partner - Master

ODBC connect in a external txt

Hi expert

i have one question about odbc to connect to sql

i have this:

ODBC CONNECT TO database (XUserID is xxx, XPassword is yyy)

if i want to create this string connection external in a txt, and not visible for the user, it could be possible to pass for parameters the user and the password?

i want that the user not create the odbc always, i will have a string by defect and the user only will pass the user and the password and the database name or server if it could.

is there any way or solution to this?

if i put my app in other place, with the same odbc only change user and password and connect

thank you a lot

Fernando

1 Solution

Accepted Solutions
fkeuroglian
Partner - Master
Partner - Master
Author

Sebastian, como estas?

muchas gracias por tu ayuda, en este link encontre lo que estaba buscando, algo asi seria

Passing userid and password to ODBC Connection

muchas gracias!saludos

Fernando

View solution in original post

10 Replies
stabben23
Partner - Master
Partner - Master

Hi, you can do it like this:

$(Must_Include=$(v.ConnStringPath)nameofile.txt);

where  v.ConnStringPath is your relative path to your file.

sebastiandperei
Specialist
Specialist

Suposing that you have a C:\ODBC.txt file with:

XUserID is xxx, XPassword is yyy


aux:

LOAD @1

FROM

(txt, codepage is 1252, explicit labels, delimiter is '\t', msq);

let odbc = Peek('@1');

drop table aux;

ODBC CONNECT TO database ($(odbx));

sebastiandperei
Specialist
Specialist

Good Staffan! I didn't knew about this sentence.

fkeuroglian
Partner - Master
Partner - Master
Author

Staffan, thank you for the answer

but my problem is not call external txt, my problem is that in my external txt there will be the string whit the paramets

ODBC CONNECT TO database (XUserID is xxx, XPassword is yyy)


but what happend if i want to user the same odbc but in another ambient(test or production) i will have to put another user and password


what can i change this? because in my string conection there will be encrypted the old user and password


thank you staffan

stabben23
Partner - Master
Partner - Master

Why do u want to switch users that have access to the database? why not always use one user that have read properties. Then you can move your file from test to prod to wherever, look into how you use connectionstrings in Deployment Framework.

fkeuroglian
Partner - Master
Partner - Master
Author

Staffan

i always will use user with read permision to acces to the data base but:

in test my database will be DBTest

my user will be: userTest

my pass will be: passTest

in prod my database will be DBProd

my user will be: userProd

my pass will be: passProd

i want ONE only string connection if i have this case

thank you a lot!

Fernando

petter
Partner - Champion III
Partner - Champion III

When it runs on a server you can't have any interaction with the user so they can pass a userid and password on demand. Then you will have to have a list of users and passwords. More practical is to have a list of different databases that will each point to Development, Test, User Acceptance and Production for instance with different userids and passwords for each.

sebastiandperei
Specialist
Specialist

Fernando, intuyo que hablás español. If not speak spanish, tell and i will traduce.

"El usuario" al que hacés referencia, es el desarrollador o el usuario final? Es quien desarrolla el script o es el que usa la aplicación?

Si es el que usa la aplicación, de antemano, no va a poder acceder a la misma desde el Access Point, ya que toda interacción con variables se hace en una instancia del usuario, y la recarga de la misma es independiente a esas modificaciones. Va a tener que acceder mediante instalación del cliente y el acceso directo al qvw. Entonces podés tener una variable que sea, por ejemplo, vBase. Puesta en un cuadro de entrada, cuyos valores puedan ser DBTest, o DBProd. Entonces manualmente va a recargar la aplicación.

En el script, si querés ponelo en una pestaña oculta, ingresá lo siguiente:

If vBase='DBTest' then

   $(Must_Include=$(v.ConnStringPath)ODBC_DBTest.txt);

ELSE

   $(Must_Include=$(v.ConnStringPath)ODBC_DBProd.txt);

ENDIF

Cada .txt contendrá los parámetros de cada base, con sus respectivos usuario y contraseña.

Si no entendí bien tu necesidad, por favor, explicámela de nuevo.

Saludos,