The Result ist -1 ???

The Result ist -1 ???

Postby ConiKost » Thu 24 Nov 2005 08:52

Hello!
I got here Visual Basic 2005 Express Edition.
I am using an PostgreSQL DB v8.0!

But the Problem is, that the resulst are just -1 ?? A connection is made successfull!

Code: Select all
Imports CoreLab.PostgreSql
Imports System

Module Module1

    Dim myConnection As New PgSqlConnection("host=153.19.72.155;database=conikost;user id=conikost")
    Dim myCommand As PgSqlCommand = New PgSqlCommand("select * from conikost")

    Public Sub PerformAsync()
        myCommand.Connection = myConnection
        myConnection.Open()
        Dim rowsAffected As Int32
        Try
            Dim myResult As IAsyncResult = myCommand.BeginExecuteNonQuery(Nothing, Nothing)
            Console.Write("In progress...")
            While Not myResult.IsCompleted
                Console.Write(".")
                'Perform here any operation you need
            End While
            rowsAffected = myCommand.EndExecuteNonQuery(myResult)
            Console.WriteLine()
            Console.WriteLine("Operation complete. Rows Affected: " & rowsAffected)
        Catch
            Console.WriteLine("Error during execution.")
        Finally
            myConnection.Close()
        End Try
    End Sub

    Sub Main()
        PerformAsync()
        Console.WriteLine("About to exit.")
        Console.ReadLine()
    End Sub
ConiKost
 
Posts: 5
Joined: Thu 24 Nov 2005 08:49

Postby SecureGen » Thu 24 Nov 2005 14:10

Result -1 is a valid result for ExecuteNonQuery()(BeginExecuteNonQuery() is just async version) when it executes SELECT statement. You can check this in the MSDN. If you expect a result set from your command use ExecuteReader() function instead.
SecureGen
Devart Team
 
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Postby ConiKost » Fri 25 Nov 2005 07:27

Hi!
Thanks for Help!
ConiKost
 
Posts: 5
Joined: Thu 24 Nov 2005 08:49

Postby SecureGen » Fri 25 Nov 2005 09:30

Please refer to our demo projects. They demonstrate how to use PostgreSQLDirect .NET for typical tasks. You can find it in the /Samples folder.
If you look at DataReader sample you can find the following code:
While DataReader.Read()
For I = 0 To DataReader.FieldCount - 1
tbResult.AppendText(DataReader.GetValue(I).ToString().PadRight(Len).Substring(0, Len) + " ")
Next I
tbResult.AppendText(R)
RecCount = RecCount + 1
End While

It can be easily adapted to your application.
SecureGen
Devart Team
 
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Postby ConiKost » Fri 25 Nov 2005 09:39

Thank You!
I found this allredy :)
ConiKost
 
Posts: 5
Joined: Thu 24 Nov 2005 08:49


Return to dotConnect for PostgreSQL