Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Posts
    5

    Unanswered: Informix table insert from VB6

    Question...

    I am inserting a record into an Informix table. One of the
    values I insert is 0 (zero) into a serial field. What I was hoping
    someone could answer is how can I retrieve the value of the
    serial field after the insert from the VB6 program?

  2. #2
    Join Date
    Jul 2003
    Posts
    2
    use DBINFO

  3. #3
    Join Date
    Aug 2003
    Location
    India
    Posts
    262

    Re: Informix table insert from VB6

    Originally posted by gsmithriv
    Question...

    I am inserting a record into an Informix table. One of the
    values I insert is 0 (zero) into a serial field. What I was hoping
    someone could answer is how can I retrieve the value of the
    serial field after the insert from the VB6 program?
    Hi there,

    check the value of sqlca.sqlerrd[2] variable. This is an informix sqlca structure. All serial value assigned to the column are stored here.

    Regards,

    lloyd

  4. #4
    Join Date
    Jul 2003
    Posts
    5

    Informix table insert from VB6

    Thank you for the help... really appreciated.

    Is it possible to access the sqlca record from within VB?

  5. #5
    Join Date
    Aug 2003
    Location
    India
    Posts
    262

    Re: Informix table insert from VB6

    Originally posted by gsmithriv
    Thank you for the help... really appreciated.

    Is it possible to access the sqlca record from within VB?
    Your welcome, I am not too sure whether we can access sqlca record from VB, maybe u can try.

  6. #6
    Join Date
    Jan 2004
    Posts
    2

    use the following code.... works for me

    declare the following function

    Public Function GetSerialNum() As Long
    Dim strSerial As String, rs_serial As New ADODB.Recordset
    strSerial = "SELECT DBINFO(""SQLCA.SQLERRD1"") FROM ST_COMPANY" (to get single return)
    CreateRecordset cnnDB, rs_serial, strSerial
    GetSerialNum = rs_serial(0)
    rs_serial.Close
    End Function

    then to use the function try the following

    strSql = "INSERT INTO ps_end_of_day VALUES(0, " & BranchID & ", '" & Format(Date, "ddmmyyyy") & "', '" & Format(Time, "hh:mm") & "', " & UserId & ")"
    cnnDB.Execute strSql
    end_serial_num = GetSerialNum

    works fine

    regards
    john

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •