Results 1 to 6 of 6

Thread: How to connect to Postgresql database

  1. #1
    Join Date
    May 2011
    Posts
    72

    How to connect to Postgresql database

    Hey friend I am new to this language and I think that would not help me out , I have been trying to use each and every method that was possible from my side ,but still not been able to connected this so please help me out , see me code :


    Code:
    dim db as PostgreSQLDatabase
    dim recordset as RecordSet
    
    call ReadSettings() ' Read an ini file.
    
    db = new PostgreSQLDatabase
    db.Host =App.Server ' Defined in the application properties
    db.Port=2343
    db.DatabaseName=App.Database
    db.UserName=App.Userid
    db.Password=App.Password
    
    if db.Connect then
    msgbox "Connect ion made "
    else
    msgbox "Connection not made "
    end if

  2. #2
    Join Date
    May 2009
    Posts
    511

    Re: How to connect to Postgresql database

    I have edited your code and here the code that should work for you now so just test it and let me know if that works for you .

    Code:
    dim db as PostgreSQLDatabase
    dim recordset as RecordSet
    
    
    call ReadSettings() ' Read an ini file.
    
    db = new PostgreSQLDatabase
    db.Host ="Localhost"
    db.Port=4572
    db.DatabaseName="Mydatabase"
    db.UserName="user name "
    db.Password="password "
    
    if db.Connect then
    msgbox "Connection made "
    else
    msgbox "Connect not made”
    end if

  3. #3
    Join Date
    Apr 2009
    Posts
    569

    Re: How to connect to Postgresql database

    I think the only problem that beginners do here is setting the breakpoint in the debugger to authenticate the properties are currently been used .If every property is accurately the identical as your hard-coded values and still does not work, then it may sounds like your properties aren't containing the values you suppose they ought to be, not a malfunction from the Postgres server or plugin. I hope that would help you out .

  4. #4
    Join Date
    May 2011
    Posts
    72

    Re: How to connect to Postgresql database

    The properties are receiving the accurate data from the ini-file that I have mentioned above. I have confirmed it by using the debugger and by by means of a message box. At the moment I include used the Postgresql oledb and it unite fine. But the standard plug-in is decline data from the properties, only hardcoded data.SO I guess rechecking all the portieres would be better useful to you as you have not been able to get a instance from there

  5. #5
    Join Date
    May 2011
    Posts
    105

    Re: How to connect to Postgresql database

    i think i should not have used Postgre on an RB project so that i would be in an better econdition to ask for help from my techers and students that already had the knowledge of the language ,i just don 't know what difference does it make when i an suing the localhost and the server that is on the same machine that i am using the , but anyany way thanks for all the repleis atleast they help me to get it solved to some extend .

  6. #6
    manimoor Guest

    How to connect to Postgresql database

    Hi..i provide some connection steps here,

    One connects to a database using the following statement:
    EXEC SQL CONNECT TO target [AS connection-name] [USER user-name];

    The target can be specified in the following ways:

    *dbname[@hostname][:port]

    *tcp:postgresql://hostname[:port][/dbname][?options]

    *unix:postgresql://hostname[:port][/dbname][?options]

    *an SQL string literal containing one of the above forms

    *a reference to a character variable containing one of the above forms (see examples)

    *DEFAULT


    If you specify the connection target literally (that is, not through a variable reference) and you don't quote the value, then the case-insensitivity rules of normal SQL are applied. In that case you can also double-quote the individual parameters separately as needed. In practice, it is probably less error-prone to use a (single-quoted) string literal or a variable reference. The connection target DEFAULT initiates a connection to the default database under the default user name. No separate user name or connection name can be specified in that case.

    There are also different ways to specify the user name:

    username

    username/password

    username IDENTIFIED BY password

    username USING password


    As above, the parameters username and password can be an SQL identifier, an SQL string literal, or a reference to a character variable.

    The connection-name is used to handle multiple connections in one program. It can be omitted if a program uses only one connection. The most recently opened connection becomes the current connection, which is used by default when an SQL statement is to be executed (see later in this chapter).

    Here are some examples of CONNECT statements:

    EXEC SQL CONNECT TO mydb@sql.mydomain.com;

    EXEC SQL CONNECT TO unix:postgresql://sql.mydomain.com/mydb AS myconnection USER john;

    EXEC SQL BEGIN DECLARE SECTION;
    const char *target = "mydb@sql.mydomain.com";
    const char *user = "john";
    EXEC SQL END DECLARE SECTION;
    ...
    EXEC SQL CONNECT TO :target USER :user;

Similar Threads

  1. Postgresql vs Mysql database
    By Xmen in forum Software Development
    Replies: 4
    Last Post: 04-03-2010, 10:11 PM
  2. How to connect ASP to different database
    By Elijah2010 in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 12:01 AM
  3. how to connect VB6 to database
    By WILTON in forum Software Development
    Replies: 3
    Last Post: 08-12-2009, 04:26 AM
  4. How to connect to MS SQL Server database?
    By Eleazar in forum Software Development
    Replies: 4
    Last Post: 11-04-2009, 11:28 AM
  5. WSUS cannot connect to database
    By Henri@ksen in forum Server Update Service
    Replies: 1
    Last Post: 16-02-2007, 10:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,078,386.61956 seconds with 17 queries