I need to use an Auto-operator script to connect to a external Database. How do I do this?

Document ID : KB000046250
Last Modified Date : 14/02/2018
Show Technical Document Details
 
 

Problem:

I tried to create a NAS Auto-operator (AO) LUA script to connect to an external database but I can not get it to work.
Can you please provide an example of making a database connection string for the NAS LUA scripting?
 

Solution:

 
When connecting to oracle, MS SQL and MySQL it is required that a working ODBC driver be installed to reference from the NAS LUS script.
 
NOTE: Please see the vendor documentation for installing drivers for the operating system in use.
 
 
 
Opens a separate SQLite database file:
          database.open("my_private.db")

Opens the NiS:
         database.open("provider=nis;database=nis;driver=none")

Opens MS Access database:
         database.open ("Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\\ myluadb.mdb;Uid=xxx;Pwd=yyy")



Connection string for MSSQL:
         database.open ("Driver={SQL Server};Data Source=Database server;Initial Catalog=Database name;User Id=Username;Password=Password;")
        Or
        database.open ("Driver={SQL Server}; Server=servername; Database=database; Uid=username; Pwd=password;")


Connection string for MySQL:
        database.open ("Driver={MySQL ODBC 5.1 Driver};Server=Database server;Option=131072;Stmt=;Database=Database name;User=Username Password=Password;")
 
Connection string for Oracle:
        database.open ("Provider=Oracle;Data Source=oracle_server;Initial Catalog=oracle_database;User ID=oracle_user;Password=oracle_pwd;ServiceName=oracle_service;Port=oracle_port;")
        Or
        Can you try to setup a system DSN with a connection string, with ODBC name equal to the Oracle SID:

           database.open("Driver={Microsoft ODBC for Oracle};Server=odbcname;UID=uid;PWD=pwd")

        If you define a system environment variable local=oracleSID then use these for Oracle:

          database.open("Provider=OraOLEDB.Oracle;database=odbcname;User ID=uid;Password=password")
          database.open("Provider=msdaora;database=odbcname;User ID=uid;Password=password")