473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

ADDITION TO RECORDSET<ERRORS

103 100+
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. txtid.Enabled = True
  3. If txtid.Text = " " Then
  4. MsgBox "Enter the id,Please!!!", vbOKOnly, "PAYROLL"
  5. txtid.SetFocus
  6. With txtid
  7. .SelStart = 0
  8. '.SelLength = Len(txtid.Text)
  9. .SetFocus
  10. End With
  11. Exit Sub
  12. ElseIf txtname.Text = " " Then
  13.  MsgBox "Enter the name,Please!!!", vbOKOnly, "PAYROLL"
  14.  'txtname.SetFocus
  15. Exit Sub
  16.  
  17.  With txtname
  18.    .SelStart = 0
  19. '  .SelLength = Len(txtname.Text)
  20.    .SetFocus
  21.  
  22. End With
  23.  'End If
  24. ElseIf txtwhr.Text = " " Then
  25. MsgBox "Enter  the working hours,Please!!!", vbOKOnly, "PAYROLL"
  26. txtwhr.SetFocus
  27. Exit Sub
  28. With txtwhr
  29.   .SelStart = 0
  30. '.SelLength = Len(txtwhr.Text)
  31.   .SetFocus
  32. End With
  33. ElseIf Form1.txtrate.Text = " " Then
  34. MsgBox "Enter  the rate,Please!!!", vbOKOnly, "PAYROLL"
  35. txtrate.SetFocus
  36. Exit Sub
  37. With txtrate
  38.   .SelStart = 0
  39.   .SetFocus
  40. End With
  41. ElseIf txtorate.Text = " " Then
  42. MsgBox "Enter the Overtime Rate,Please!!!", vbOKOnly, "PAYROLL"
  43. txtorate.SetFocus
  44.  Exit Sub
  45. With txtorate
  46.  .SelStart = 0
  47.   .SetFocus
  48.   End With
  49.   Else
  50. rs.Open "select * from empdetail Where ID='" & txtid.Text & "'", conn, adOpenStatic, adLockOptimistic
  51. If rs.EOF Then
  52. conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
  53. MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
  54. Else
  55.  
  56. MsgBox "Duplicate Entry"
  57.   End If
  58.  
  59. rs.Close
  60. Set rs = Nothing
  61. ListView1.ListItems.Clear
  62. addcol
  63. Form1.txtid.Text = ""
  64. Form1.txtname.Text = ""
  65. Form1.txtwhr.Text = ""
  66. Form1.txtrate.Text = ""
  67. Form1.txtorate.Text = ""
  68. End If
  69.  
  70. End Sub
  71. Private Sub cmdBack_Click()
  72. Form1.txtid.Text = ""
  73. Form1.txtname.Text = ""
  74. Form1.txtwhr.Text = ""
  75. Form1.txtrate.Text = ""
  76. Form1.txtorate.Text = ""
  77. Form1.Hide
  78. MDIForm1.Show
  79. End Sub

This above code is for adding four fields to databse where id the primary kiey.Please go through because,its works for once,ie when one data gets inserted,u dont have any pblm.But whenthe computation is done for the second time without closing the window,an error occurs!!!
Please Go through...........!!!!!~
Where I HAve go wrong????
Jan 11 '08 #1
3 1188
Dököll
2,364 Expert 2GB
code:vb

This above code is for adding four fields to databse where id the primary kiey.Please go through because,its works for once,ie when one data gets inserted,u dont have any pblm.But whenthe computation is done for the second time without closing the window,an error occurs!!!
Please Go through...........!!!!!~
Where I HAve go wrong????
Hello, Vbbeginner07!

What are you hoping the above code does?

I am just trying to get a handle on what you are asking for. Can you go into it a little more?

Dököll
Jan 11 '08 #2
Vbbeginner07
103 100+
Hello, Vbbeginner07!
What are you hoping the above code does?
I am just trying to get a handle on what you are asking for. Can you go into it a little more?
Dököll
Hi DoKoll,
the above code is for ADD ing datas to a database,the form actually contains five fileds
id ,which is the primary key
name(of employee)
working hours(emp)
rate(per hours)
overtime rate(if he does,per hours)
The code works for the very first time,ie when one data gets inserted into the database,if we click ADD button(command button)it gives errors,where i have given specific constraints for each field,why is it so...???
Where i have gone wrong???
Ant More explanation???

Nick
Jan 11 '08 #3
debasisdas
8,127 Expert 4TB
please try to use this

Expand|Select|Wrap|Line Numbers
  1. conn.BeginTrans
  2. conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
  3. conn.commmittrans
  4.  
that might help you.
Jan 11 '08 #4

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

Similar topics

2
by: Adrian Parker | last post by:
I'm reading/writing from Access using both EXECUTE() and Recordset methods. I get weird errors though. For example I have 5 text boxes bound to fields. I will change the data in a couple of the...
0
by: kinane3 | last post by:
I'm guessing this has something to do with my cursor but I'm not sure. this is for a picture gallery app and when I upload pictures some pictures or records don't show up. this is what ia have so...
1
by: Ranjith Venkatesh | last post by:
I read and write to a config file which is the data store for this Windows Application written in C# using VS.NET 2003 in Windows XP. Now I want to trigger the program to read the config whenever...
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
7
by: brett.estabrook | last post by:
I have written a multi-threaded c# windows service in .net 1.1 (Visual Studio .net 2003). The service has several threads that poll a Sql 6.5 database on another machine. Each thread will execute a...
11
by: Holger | last post by:
Hi I have not been able to figure out how to do compound statement from C - "<test>?<true-val>:<false-val>" But something similar must exist...?! I would like to do the equivalent if python...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
10
by: CuTe_Engineer | last post by:
hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.