By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,189 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,189 IT Pros & Developers. It's quick & easy.

it shows 3265 error number while saving data

P: 2
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdsave_Click()
  2.  rs.Fields("Emp_id") = cmbempid.Text
  3.  rs.Fields("Absent_date") = lbldate2.Caption//it shows here
  4.  If optabsent.Value = True Then
  5.  rs.Fields("Emp_status") = "absent"
  6.  Else
  7.  rs.Fields("Emp_status") = "latemark"
  8.  End If
  9.  If optapprove.Value = True Then
  10.  rs.Fields("cneck_record") = 1
  11.  Else
  12.  rs.Fields("cneck_record") = 0
  13.  End If
  14. rs.Fields("Leave_type") = txtlname.Text
  15. rs.Update
  16.  cmdfirst.Enabled = True
  17.  cmdlast.Enabled = True
  18.  cmdnext.Enabled = True
  19.  cmdprevious.Enabled = True
  20.  cmdexit.Enabled = True
  21.  cmdadd.Enabled = True
  22.  cmdmodify.Enabled = True
  23.  cmddelete.Enabled = True
  24.  cmdcancel.Enabled = True
  25. End Sub
  26.  
  27. Private Sub Form_Load()
  28. con.Open _
  29. "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=leave;Data Source=ABC"
  30. 'con.Execute "set nocount on"
  31. substring = "select* from muster"
  32. 'rs.CursorLocation = adUseServer
  33. 'rs.Open substring, con, adOpenStatic, adLockPessimistic
  34. With rs
  35.     .CursorType = adOpenStatic
  36.     .CursorLocation = adUseClient
  37.     .LockType = adLockOptimistic
  38.     .ActiveConnection = con
  39.     'Set .ActiveConnection = Nothing
  40. End With
  41. rs.Open substring
  42. 'con.Execute (substring),
  43. 'rs.CursorLocation = adUseServer
  44. substring1 = "select * from Employee"
  45. rs1.Open substring1, con, adOpenDynamic, adLockOptimistic
  46. lbldate2.Caption = Date
  47. substring3 = "select * from leave"
  48. rs2.Open substring3, con, adOpenDynamic, adLockOptimistic
  49. 'cmbempid.AddItem (Form1.txtempno.Text)
  50. Do While Not rs1.EOF
  51.    cmbempid.AddItem rs1(0)
  52.    rs1.MoveNext
  53. Loop
  54. substring4 = " select * from leave_taken"
  55. rs3.Open substring4, con, adOpenDynamic, adLockOptimistic
  56. Dim substring5 As String
  57. Dim int1 As Integer
  58. substring5 = "select distinct emp_id from muster where Leave_type like 'nil'"
  59. If rs.State = adStateOpen Then
  60. rs.Close
  61. End If
  62. rs.Open substring5, con, adOpenDynamic, adLockOptimistic
  63. 'int1 = CInt(Trim(substring5))
  64. If rs.BOF = False Or rs.EOF = False Then
  65. rs.MoveNext
  66. MsgBox "There are 'nil' employee leave type not consider are " & rs.Fields("Emp_id").Value
  67. End If
  68. Call getdata
  69. 'optabsent.Value = False
  70. End Sub
  71. Private Sub optabsent_Click()
  72. optapprove.Enabled = True
  73. optdisapp.Enabled = True
  74. 'optlatemark.Enabled = False
  75. 'If optabsent = True Then
  76.  '  If optapprove = True Then
  77.   '   txtletype.Visible = True
  78.   '   txttotal.Visible = False
  79.    'Else
  80.     ' txtletype.Text = "Nil"
  81.      'txttotal.Visible = True
  82.   'End If
  83. 'Else
  84. '  optapprove.Value = False
  85. '  optdisapp.Value = False
  86.  ' txtletype.Visible = False
  87. 'End If
  88. End Sub
  89.  
  90.  
I check my all feilds in the table all are the correct but it still show the error like this.
Jun 10 '08 #1
Share this Question
Share on Google+
1 Reply


lotus18
100+
P: 866
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.

Expand|Select|Wrap|Line Numbers
  1. Call setCon  
  2. rs.Open "Select * From Musters", con, 3, 3
  3. rs.AddNew
  4. <Your codes here....>
  5. rs.Update
  6.  
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
Jun 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.