KB-39000: Adding a record into a PostgreSQL Database.

NOTE: From Elipse E3 version 6.5 on, the supervisory has featured native connection to PostgreSQL. This article applies to versions prior to 6.5.

Question:

How can I add a record into a PostgreSQL Database?

 

Solution:

To do so, you must create the connection via scripts, since this Database is not native to E3. For example:

‘Creates the connection to the database
Set db_con = CreateObject(“ADODB.Connection”)

str_con = “Driver={PostgreSQL ODBC Driver(ANSI)};Server=localhost;Port=5432;Database=postgres;Uid=postgres;Pwd=Abcd1234”

db_con.Open str_con

‘Creates the recordset
Set rs = CreateObject(“ADODB.Recordset”)
rs.Source = “INSERT INTO tabelateste3 VALUES (‘1/1/1958’, ‘0’)”
rs.ActiveConnection = db_con
rs.CursorType = 1 ‘adOpenKeyset
rs.LockType = 3 ‘adLockOptimistic
rs.Open

NOTE: for this example, consider this table as having already been created in the Database.

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *