it shows 3265 error number while saving data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhavika123456
    New Member
    • Jun 2008
    • 2

    it shows 3265 error number while saving data

    Code:
    Private Sub cmdsave_Click()
     rs.Fields("Emp_id") = cmbempid.Text
     rs.Fields("Absent_date") = lbldate2.Caption//it shows here
     If optabsent.Value = True Then
     rs.Fields("Emp_status") = "absent"
     Else
     rs.Fields("Emp_status") = "latemark"
     End If
     If optapprove.Value = True Then
     rs.Fields("cneck_record") = 1
     Else
     rs.Fields("cneck_record") = 0
     End If
    rs.Fields("Leave_type") = txtlname.Text
    rs.Update
     cmdfirst.Enabled = True
     cmdlast.Enabled = True
     cmdnext.Enabled = True
     cmdprevious.Enabled = True
     cmdexit.Enabled = True
     cmdadd.Enabled = True
     cmdmodify.Enabled = True
     cmddelete.Enabled = True
     cmdcancel.Enabled = True
    End Sub
    
    Private Sub Form_Load()
    con.Open _
    "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=leave;Data Source=ABC"
    'con.Execute "set nocount on"
    substring = "select* from muster"
    'rs.CursorLocation = adUseServer
    'rs.Open substring, con, adOpenStatic, adLockPessimistic
    With rs
        .CursorType = adOpenStatic
        .CursorLocation = adUseClient
        .LockType = adLockOptimistic
        .ActiveConnection = con
        'Set .ActiveConnection = Nothing
    End With
    rs.Open substring
    'con.Execute (substring),
    'rs.CursorLocation = adUseServer
    substring1 = "select * from Employee"
    rs1.Open substring1, con, adOpenDynamic, adLockOptimistic
    lbldate2.Caption = Date
    substring3 = "select * from leave"
    rs2.Open substring3, con, adOpenDynamic, adLockOptimistic
    'cmbempid.AddItem (Form1.txtempno.Text)
    Do While Not rs1.EOF
       cmbempid.AddItem rs1(0)
       rs1.MoveNext
    Loop
    substring4 = " select * from leave_taken"
    rs3.Open substring4, con, adOpenDynamic, adLockOptimistic
    Dim substring5 As String
    Dim int1 As Integer
    substring5 = "select distinct emp_id from muster where Leave_type like 'nil'"
    If rs.State = adStateOpen Then
    rs.Close
    End If
    rs.Open substring5, con, adOpenDynamic, adLockOptimistic
    'int1 = CInt(Trim(substring5))
    If rs.BOF = False Or rs.EOF = False Then
    rs.MoveNext
    MsgBox "There are 'nil' employee leave type not consider are " & rs.Fields("Emp_id").Value
    End If
    Call getdata
    'optabsent.Value = False
    End Sub
    Private Sub optabsent_Click()
    optapprove.Enabled = True
    optdisapp.Enabled = True
    'optlatemark.Enabled = False
    'If optabsent = True Then
     '  If optapprove = True Then
      '   txtletype.Visible = True
      '   txttotal.Visible = False
       'Else
        ' txtletype.Text = "Nil"
         'txttotal.Visible = True
      'End If
    'Else
    '  optapprove.Value = False
    '  optdisapp.Value = False
     ' txtletype.Visible = False
    'End If
    End Sub
    I check my all feilds in the table all are the correct but it still show the error like this.
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    So where is the rs.AddNew on the cmdSave_Click event?

    If you are sure with fields I think the reason would be in recordset. Try to create a new public sub procedures (e.g. setCon) and put all your codes in opening your database connection.

    Try to open your recordset before adding the new values.

    [CODE=vb]
    Call setCon
    rs.Open "Select * From Musters", con, 3, 3
    rs.AddNew
    <Your codes here....>
    rs.Update
    [/CODE]

    Don't forget to close the connection as well as the recordet

    But I'd suggest you use con.Execute procedure rather than opening the recordset. : )

    Rey Sean

    Comment

    Working...