'With Powershell create new Pervasive ODBC with new database
I would like to create in Powershell a 32 bits ODBC connection to a Pervasive Database. I have the following that works:
Add-OdbcDsn -Name "dbcon" -DriverName "Pervasive ODBC Engine Interface" -DsnType "User" -Platform "32-bit" -SetPropertyValue "Dbq=GENERAL"
The problem is that I want to create a new database pointing to a specific folder. Steps in the UI.
Hit create.
Fill in the dictionary location.
NOTE
Add-OdbcDsn -Name "dbcon" -DriverName "Pervasive ODBC Engine Interface" -DsnType "User" -Platform "32-bit" -SetPropertyValue @("DBALIAS=GENERAL2","Description=General","DictionaryLocation=C:\mylocation","DataFileLocation=C:\mylocation")
And it gave the following error:
Add-OdbcDsn : Driver's ConfigDSN, ConfigDriver, or ConfigTranslator failed (Installer error code: 11).
Solution 1:[1]
I did do some fiddling in Powershell, and this creates a database:
I tested with "Zen Enterprise v15 Community Edition 1-user for Linux 64-bit." but this should work with other versions too.
$database, $dictionary_path, $data_path and SERVERNAME need to be changed to your likings.
Add-Type -Path "C:\Program Files (x86)\Actian\Zen\bin\ADONET4.5\Pervasive.Data.Common.dll"
Add-Type -Path "C:\Program Files (x86)\Actian\Zen\bin\ADONET4.5\Pervasive.Data.SqlClient.dll"
$p = new-object Pervasive.Data.SqlClient.PsqlConnection("server=SERVERNAME")
$p.Open()
$database = "TEST"
$dictionary_path = "/usr/local/actianzen/data/TEST"
$data_path = "/usr/local/actianzen/data/TEST"
$sql = "CREATE DATABASE IF NOT EXISTS $database DICTIONARY_PATH '$dictionary_path' DATA_PATH '$data_path' "
$cmd = $p.CreateCommand()
$cmd.CommandText = $sql
$x = $cmd.ExecuteNonQuery();
$p.Close();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Luuk |


