Results 1 to 8 of 8
  1. #1

    Default Error handling/trapping in vb using ibm database


    Guys, do you have any idea about error trapping in save and handling using the ibm database program .im using the vb to manipulate ibm database program...

  2. #2
    defaultButtons
    On Error GoTo errSave
    'On Error Resume Next
    Dim sqlstr As String
    Dim rs As ADODB.Recordset

    If NewEdit = "" Then
    rs.Open " select * from employee where empno ='" & txtEmpNum & "'"



    'If txtEmpNum.Text = " " Then
    'MsgBox " DON'T LEAVE IT BLANK"
    '
    If rs.EOF Then
    'Exit Sub
    If NewEdit = 1 Then
    db2Conn.BeginTrans
    db2Conn.Execute "INSERT INTO Employee(EMPNO,FIRSTNME,MIDINIT,LASTNAME,WORKDEPT, PHONENO,HIREDATE,JOB,EDLEVEL,***,BIRTHDATE,SALARY, BONUS,COMM) VALUES ('" & txtEmpNum.Text & "','" & txtFirstNme.Text & "','" & txtMidinit.Text & "','" & txtLastName.Text & "','" & txtWorkdept.Text & "','" & txtPHONENO.Text & "', '" & DTHIREDATE.Value & "','" & txtJOB.Text & "'," & Val(txtEdlevel.Text) & ",'" & TXTSEX.Text & "','" & BDATE.Value & "'," & Val(txtSalary.Text) & ", " & Val(txtBONUS.Text) & "," & Val(txtCOMM.Text) & ")"
    MsgBox "RECORD SUCCESSFULLY SAVED"
    Exit Sub
    Else

    MsgBox "Duplicate Stock Code. Please review your entries!!", vbCritical, Me.Caption
    End If
    Else
    db2Conn.Execute "UPDATE employee set firstnme = '" & Left(txtFirstNme.Text, 12) & "',midinit = '" & Left(txtMidinit.Text, 1) & "',lastname = '" & Left(txtLastName.Text, 15) & "', workdept = '" & Left(txtWorkdept.Text, 3) & "',Phoneno = '" & Left(txtPHONENO.Text, 4) & "',HIREDATE = '" & DTHIREDATE.Value & "', JOB = '" & Left(txtJOB.Text, & "',EDLEVEL = " & Val(txtEdlevel.Text) & " , *** = '" & TXTSEX.Text & "' , BIRTHDATE= '" & BDATE.Value & "', SALARY = " & Val(txtSalary.Text) & ", BONUS = " & Val(txtBONUS.Text) & ", COMM = " & Val(txtCOMM.Text) & " where empno = '" & txtEmpNum.Text & "'"
    MsgBox "SUCCESSFULLY UPDATED"
    Exit Sub
    End If
    End If


    db2Conn.CommitTrans
    clearTxt
    errExit:
    Exit Sub
    errSave:

    db2Conn.RollbackTrans
    MsgBox Err.Description, vbCritical, "ERROR:" & Me.Caption
    Resume errExit
    cmdSave.Enabled = True
    cmdNew.Enabled = False
    cmdDelete.Enabled = False
    cmdEdit.Enabled = False

  3. #3
    defaultButtons
    On Error GoTo errSave
    Dim sqlstr As String
    Dim rs As ADODB.Recordset

    If len(txtEmpNum.Text)=0 Then
    MsgBox " DON'T LEAVE IT BLANK"
    Exit Sub
    End If


    If NewEdit = "" Then
    rs.Open " select * from employee where empno ='" & txtEmpNum & "'"

    If rs.EOF Then
    If NewEdit = 1 Then
    db2Conn.BeginTrans
    db2Conn.Execute "INSERT INTO Employee(EMPNO,FIRSTNME,MIDINIT,LASTNAME,WORKDEPT, PHONENO,HIREDATE,JOB,EDLEVEL,***,BIRTHDATE,SALARY, BONUS,COMM) VALUES ('" & txtEmpNum.Text & "','" & txtFirstNme.Text & "','" & txtMidinit.Text & "','" & txtLastName.Text & "','" & txtWorkdept.Text & "','" & txtPHONENO.Text & "', '" & DTHIREDATE.Value & "','" & txtJOB.Text & "'," & Val(txtEdlevel.Text) & ",'" & TXTSEX.Text & "','" & BDATE.Value & "'," & Val(txtSalary.Text) & ", " & Val(txtBONUS.Text) & "," & Val(txtCOMM.Text) & ")"
    MsgBox "RECORD SUCCESSFULLY SAVED"
    Else

    MsgBox "Duplicate Stock Code. Please review your entries!!", vbCritical, Me.Caption
    End If
    Else
    db2Conn.Execute "UPDATE employee set firstnme = '" & Left(txtFirstNme.Text, 12) & "',midinit = '" & Left(txtMidinit.Text, 1) & "',lastname = '" & Left(txtLastName.Text, 15) & "', workdept = '" & Left(txtWorkdept.Text, 3) & "',Phoneno = '" & Left(txtPHONENO.Text, 4) & "',HIREDATE = '" & DTHIREDATE.Value & "', JOB = '" & Left(txtJOB.Text, & "',EDLEVEL = " & Val(txtEdlevel.Text) & " , *** = '" & TXTSEX.Text & "' , BIRTHDATE= '" & BDATE.Value & "', SALARY = " & Val(txtSalary.Text) & ", BONUS = " & Val(txtBONUS.Text) & ", COMM = " & Val(txtCOMM.Text) & " where empno = '" & txtEmpNum.Text & "'"
    MsgBox "SUCCESSFULLY UPDATED"

    End If
    End If

    db2Conn.CommitTrans

    clearTxt

    errExit:
    rs.close
    Set rs=nothing
    Exit Sub
    errSave:

    db2Conn.RollbackTrans
    MsgBox Err.Description, vbCritical, "ERROR:" & Me.Caption
    Resume errExit
    cmdSave.Enabled = True
    cmdNew.Enabled = False
    cmdDelete.Enabled = False
    cmdEdit.Enabled = False

    ''----------------------------------------------------
    ''just modify your code..
    ''remove exit sub after the 2 messagebox so that
    db2Conn.CommitTrans
    ClearTxt
    ''will be executed by the program..

    ''try to check your Insert Into and Update statement..

    ''happy coding..

  4. #4
    Quote Originally Posted by rhex_tendo View Post
    defaultButtons
    On Error GoTo errSave
    Dim sqlstr As String
    Dim rs As ADODB.Recordset

    If len(txtEmpNum.Text)=0 Then
    MsgBox " DON'T LEAVE IT BLANK"
    Exit Sub
    End If

    If NewEdit = "" Then
    rs.Open " select * from employee where empno ='" & txtEmpNum & "'"

    If rs.EOF Then
    If NewEdit = 1 Then
    db2Conn.BeginTrans
    db2Conn.Execute "INSERT INTO Employee(EMPNO,FIRSTNME,MIDINIT,LASTNAME,WORKDEPT, PHONENO,HIREDATE,JOB,EDLEVEL,***,BIRTHDATE,SALARY, BONUS,COMM) VALUES ('" & txtEmpNum.Text & "','" & txtFirstNme.Text & "','" & txtMidinit.Text & "','" & txtLastName.Text & "','" & txtWorkdept.Text & "','" & txtPHONENO.Text & "', '" & DTHIREDATE.Value & "','" & txtJOB.Text & "'," & Val(txtEdlevel.Text) & ",'" & TXTSEX.Text & "','" & BDATE.Value & "'," & Val(txtSalary.Text) & ", " & Val(txtBONUS.Text) & "," & Val(txtCOMM.Text) & ")"
    MsgBox "RECORD SUCCESSFULLY SAVED"
    Else

    MsgBox "Duplicate Stock Code. Please review your entries!!", vbCritical, Me.Caption
    End If
    Else
    db2Conn.Execute "UPDATE employee set firstnme = '" & Left(txtFirstNme.Text, 12) & "',midinit = '" & Left(txtMidinit.Text, 1) & "',lastname = '" & Left(txtLastName.Text, 15) & "', workdept = '" & Left(txtWorkdept.Text, 3) & "',Phoneno = '" & Left(txtPHONENO.Text, 4) & "',HIREDATE = '" & DTHIREDATE.Value & "', JOB = '" & Left(txtJOB.Text, & "',EDLEVEL = " & Val(txtEdlevel.Text) & " , *** = '" & TXTSEX.Text & "' , BIRTHDATE= '" & BDATE.Value & "', SALARY = " & Val(txtSalary.Text) & ", BONUS = " & Val(txtBONUS.Text) & ", COMM = " & Val(txtCOMM.Text) & " where empno = '" & txtEmpNum.Text & "'"
    MsgBox "SUCCESSFULLY UPDATED"

    End If
    End If

    db2Conn.CommitTrans

    clearTxt

    errExit:
    rs.close
    Set rs=nothing
    Exit Sub
    errSave:

    db2Conn.RollbackTrans
    MsgBox Err.Description, vbCritical, "ERROR:" & Me.Caption
    Resume errExit
    cmdSave.Enabled = True
    cmdNew.Enabled = False
    cmdDelete.Enabled = False
    cmdEdit.Enabled = False

    ''----------------------------------------------------
    ''just modify your code..
    ''remove exit sub after the 2 messagebox so that
    db2Conn.CommitTrans
    ClearTxt
    ''will be executed by the program..

    ''try to check your Insert Into and Update statement..

    ''happy coding..
    na sulayan na ni nimu bro?

  5. #5
    no active g hapon transaction bro...then ika human object not declared daw?

  6. #6
    Quote Originally Posted by istoryansucks View Post
    no active g hapon transaction bro...then ika human object not declared daw?
    'ang db2Conn.BeginTrans ibalhin igbaw sa If NewEdit = "" Then


    'asa nga line of code mg.object not declared??

  7. #7
    Quote Originally Posted by rhex_tendo View Post
    'ang db2Conn.BeginTrans ibalhin igbaw sa If NewEdit = "" Then


    'asa nga line of code mg.object not declared??
    i tried bai mao lang g hapon e teamviewer na lang kaha nako bai?just for u to see asa ko dapita na sayop then u could also give me an advice sad

  8. #8
    'pm me bro

  9.    Advertisement

Similar Threads

 
  1. databinding in listbox using vb.net 2005
    By peterparker in forum Programming
    Replies: 4
    Last Post: 10-12-2010, 08:21 PM
  2. transrollback error in vb
    By skeptic_rob in forum Programming
    Replies: 1
    Last Post: 08-05-2010, 09:58 PM
  3. Replies: 1
    Last Post: 04-02-2009, 08:41 AM
  4. How To use the DLL's in VB.net
    By pitbull147 in forum Programming
    Replies: 3
    Last Post: 09-23-2008, 06:11 PM
  5. Using custom cursors in VB.NET
    By DeathFox in forum Programming
    Replies: 0
    Last Post: 11-25-2007, 09:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top