problem with datatype timestamp

problem with datatype timestamp

Postby heme » Mon 24 Jan 2005 07:59

:cry: Hello
hi,

I am using the PostgreSQLDirect .NET 2.00 beta for .NET Framework 1.x

if i make a
select * from table1
to a table with a fild from type timestamp(0) then
the error message comes:
"System.FormatException: Die Zeichenfolge wurde nicht als gültiges DateTime erkannt.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDateTime(IFormatProvider provider)
at System.Convert.ToDateTime(Object value)
at System.Data.Common.DateTimeStorage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)<2005-01-24 08:11:03.> konnte nicht in der aend_datum-Spalte gespeichert werden. Erwarteter Typ: DateTime."

can you help me?
heme
heme
 

problem with datatype timestamp

Postby Yuri » Mon 24 Jan 2005 08:29

Please send us the code fragment to demonstrate the problem. Also include script required to create tables with data.
This problem is probably solved in PostgreSQLDirect 2.0, which will be released in a week.
Yuri
 
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Re: problem with datatype timestamp

Postby Guest » Tue 25 Jan 2005 08:01

Yuri wrote:Please send us the code fragment to demonstrate the problem. Also include script required to create tables with data.
This problem is probably solved in PostgreSQLDirect 2.0, which will be released in a week.


This is the Tabledefinition:
Code: Select all
CREATE TABLE table1 (
    lan_id integer NOT NULL,
    lan_bezeichnung character varying(30) NOT NULL,
    aend_user character varying(20),
    aend_datum timestamp(0) without time zone
);

ALTER TABLE public.table1 OWNER TO "PostGre";

insert into table1 (lan_id, lan_bezeichnung, aend_user, aend_datum)
VALUES (1,'Deutschland','ben1','2005-01-22 01:00');

insert into table1 (lan_id, lan_bezeichnung, aend_user, aend_datum)
VALUES (2,'Deutschland','ben2','2005-01-23 09:00');


And this is the VB .net-Code:
Code: Select all
Option Explicit On
Imports System
Imports System.Data
Imports CoreLab.PostgreSql

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Vom Windows Form Designer generierter Code "

    Public Sub New()
        MyBase.New()

        ' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
        InitializeComponent()

        ' Initialisierungen nach dem Aufruf InitializeComponent() hinzufügen

    End Sub

    ' Die Form überschreibt den Löschvorgang der Basisklasse, um Komponenten zu bereinigen.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    ' Für Windows Form-Designer erforderlich
    Private components As System.ComponentModel.IContainer

    'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
    'Sie kann mit dem Windows Form-Designer modifiziert werden.
    'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
    Friend WithEvents btnMakeError As System.Windows.Forms.Button
    Friend WithEvents txtLanBezeichnung As System.Windows.Forms.TextBox
    Friend WithEvents txtLanID As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtChangeDate As System.Windows.Forms.TextBox
    Private Sub InitializeComponent()
        Me.btnMakeError = New System.Windows.Forms.Button()
        Me.txtLanBezeichnung = New System.Windows.Forms.TextBox()
        Me.txtLanID = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.txtChangeDate = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'btnMakeError
        '
        Me.btnMakeError.Location = New System.Drawing.Point(95, 15)
        Me.btnMakeError.Name = "btnMakeError"
        Me.btnMakeError.Size = New System.Drawing.Size(137, 41)
        Me.btnMakeError.TabIndex = 0
        Me.btnMakeError.Text = "MakeError by reading from Database"
        '
        'txtLanBezeichnung
        '
        Me.txtLanBezeichnung.Location = New System.Drawing.Point(117, 120)
        Me.txtLanBezeichnung.Name = "txtLanBezeichnung"
        Me.txtLanBezeichnung.TabIndex = 1
        Me.txtLanBezeichnung.Text = ""
        '
        'txtLanID
        '
        Me.txtLanID.Location = New System.Drawing.Point(117, 90)
        Me.txtLanID.Name = "txtLanID"
        Me.txtLanID.TabIndex = 2
        Me.txtLanID.Text = ""
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(93, 95)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(15, 13)
        Me.Label1.TabIndex = 3
        Me.Label1.Text = "ID"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(38, 123)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(70, 13)
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "Bezeichnung"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(40, 154)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(68, 13)
        Me.Label3.TabIndex = 6
        Me.Label3.Text = "ChangeDate"
        '
        'txtChangeDate
        '
        Me.txtChangeDate.Location = New System.Drawing.Point(117, 151)
        Me.txtChangeDate.Name = "txtChangeDate"
        Me.txtChangeDate.TabIndex = 5
        Me.txtChangeDate.Text = ""
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(338, 223)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.txtChangeDate, Me.Label2, Me.Label1, Me.txtLanID, Me.txtLanBezeichnung, Me.btnMakeError})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim Conn As New CoreLab.PostgreSql.PgSqlConnection()
    'Without aend_datum it's OK
    'Dim SQL As String = "SELECT lan_id, lan_bezeichnung FROM Table1"
    Dim SQL As String = "SELECT lan_id, lan_bezeichnung, aend_datum FROM Table1"
    Dim DS As New DataSet()
    Dim TB As DataTable
    Dim DA As New PgSqlDataAdapter()
    Dim cmd As PgSqlCommand


    Private Sub btnMakeError_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMakeError.Click
        Conn.Host = "155.128.2.8"
        Conn.Database = "test"
        Conn.UserId = "PostGre"
        Conn.Password = "postgre"

        Try
            Conn.Open()
            cmd = New PgSqlCommand(SQL, Conn)
            DA.SelectCommand = cmd
            DA.Fill(DS)
            cmd.Dispose()
            TB = DS.Tables(0)
            txtLanID.DataBindings.Add("Text", TB, "lan_id")
            txtLanBezeichnung.DataBindings.Add("Text", TB, "lan_bezeichnung")
            txtChangeDate.DataBindings.Add("Text", TB, "aend_datum")


        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
            Conn.Close()

        Finally
            cmd.Dispose()
        End Try
    End Sub

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Conn.Close()
    End Sub
End Class

[/code]
Guest
 

problem with datatype timestamp

Postby Yuri » Tue 25 Jan 2005 09:29

Thank you for detailed example.
We could reproduce the problem with Beta version of the provider. This problem has already been fixed in PostgreSQLDirect .NET 2.0 Release.
Please download the new version from our site.
Yuri
 
Posts: 140
Joined: Mon 08 Nov 2004 12:07


Return to dotConnect for PostgreSQL