473,405 Members | 2,282 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,405 software developers and data experts.

Please Check the code

103 100+
THE FOLLOWING CODE INSERTS A PARTICULAR DATA INTO THE recordset WHICH IS THE FIRST FORM!!!
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select * from empdetail Where ID='" & txtid.Text & "'", conn, adOpenStatic, adLockOptimistic
  2. If rs.EOF Then
  3. conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
  4. MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
  5. Else
  6.  
THE SECONF FORM CONTAINS A LISTVIEW ,WHICH HAS TO DISPLAY THE RECORDS saved through FORM 1
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select distinct empdetail.name,saldetail1.id from empdetail,saldetail1 where saldetail1.id = empdetail.id", conn, adOpenStatic, adLockOptimistic
  2. If Not rs.EOF Then
  3. rs.MoveFirst
  4.  Do While Not rs.EOF
  5.   With ListView1
  6.      Set lvitem = ListView1.ListItems.Add(, , rs!id)
  7.      lvitem.SubItems(1) = rs!Name
  8.      rs.MoveNext
  9.      End With
  10.     Loop
  11. End If
  12. rs.Close
  13. Set rs = Nothing
  14. ListView1.Refresh
  15. ListView2.Refresh
  16.  
BUT THAT IS NOT WORKING!~!!!,
the code displays only the first inserted record in ht listview,but htt nexrt added records is not dispalying
PLEASE SUGGEST<THNAKS IN ADVANCE!!!
Feb 13 '08 #1
13 1338
debasisdas
8,127 Expert 4TB
try using 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.commitrans
  4.  
Feb 13 '08 #2
Vbbeginner07
103 100+
try using 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.commitrans
  4.  
Debasis not working.........
Please go through my code n please suggest......
Nick
Feb 13 '08 #3
Vbbeginner07
103 100+
Debasis,its not working.........
Please go through my code n please suggest......
Nick
Debasis,its not working.........
Please go through my code n please suggest......
it allows only the first records being added,if we checks form2 that will be displayed,but if we add any records second time it is not displayed
Feb 14 '08 #4
debasisdas
8,127 Expert 4TB
If both of your forms are opened at the same time you need to fresh the recordset in form2 after adding the recods in form1.
Feb 14 '08 #5
Vbbeginner07
103 100+
If both of your forms are opened at the same time you need to fresh the recordset in form2 after adding the recods in form1.
not two recordsets are opened at the sametime,n tell me how a sql recoredset be refreshed???tell me the code to refersh
NICK
Feb 14 '08 #6
mafaisal
142 100+
Hello
try this
Expand|Select|Wrap|Line Numbers
  1. if Rs.state =1 then rs.close
  2.  
not two recordsets are opened at the sametime,n tell me how a sql recoredset be refreshed???tell me the code to refersh
NICK
Feb 14 '08 #7
debasisdas
8,127 Expert 4TB
try to use this

Expand|Select|Wrap|Line Numbers
  1. rs.Requery
  2.  
Feb 14 '08 #8
QVeen72
1,445 Expert 1GB
Hi,

After looking at your Code, I feel that, You Query for EmpID, If No Record is found, then You add /Insert One Record. So at any given time, Only one Related EmpID is there in the Detail Table. So the ListView Shows only one Record.. Any kind of Re-Freshing the RecordSet will fetch you only One Record.
You can Cross-Check by Actual Querying the data in the Table


Regards
Veena
Feb 14 '08 #9
Vbbeginner07
103 100+
try to use this

Expand|Select|Wrap|Line Numbers
  1. rs.Requery
  2.  
rs.requery is not working i have tried this,but i dont think there's a option for refreshing in sql...if any please suggest
NICK
Feb 14 '08 #10
Vbbeginner07
103 100+
Hi,
After looking at your Code, I feel that, You Query for EmpID, If No Record is found, then You add /Insert One Record. So at any given time, Only one Related EmpID is there in the Detail Table. So the ListView Shows only one Record.. Any kind of Re-Freshing the RecordSet will fetch you only One Record.
You can Cross-Check by Actual Querying the data in the Table
Regards
Veena
Veena,i couldnt understand,what u have pointed out and the method suggested"
You can Cross-Check by Actual Querying the data in the Table "
Please explain and the code for adding records are:
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select * from empdetail Where ID='" & txtid.Text & "'", conn, adOpenStatic, adLockOptimistic
  2. If rs.EOF Then
  3. conn.BeginTrans
  4. conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
  5. conn.CommitTrans
  6. MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
  7. Else
  8. 'ID Found In DB (Duplicate)
  9. MsgBox "Duplicate Entry"
  10. End If
  11.  
Nick
Feb 14 '08 #11
QVeen72
1,445 Expert 1GB
Hi,

If you are using Access, Open the Access, and Find how many records are thre in EmpDetail and SalDetail Tables, and ow many of them Match (having same EmpID)

Regards
Veena
Feb 14 '08 #12
Vbbeginner07
103 100+
Hi,
if you are using Access, Open the Access, and Find how many records are thre in EmpDetail and SalDetail Tables, and ow many of them Match (having same EmpID)
Regards
Veena
Ok,but im using sql server...the same can be done here too???

NICK
Feb 15 '08 #13
QVeen72
1,445 Expert 1GB
Hi,

If you are using SQL Server, Query the table Data in ISQL/W Or Enterprise Manager's Query Tool..

REgards
Veena
Feb 15 '08 #14

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

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
1
by: Pax S | last post by:
I need a button that will check (make true) two check boxes (fields) For the record that has the focus (the record on the form that I am presently looking at). The two check boxes would be like a...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
4
by: Gary | last post by:
Hello, I'm hoping someone can shed some light on why my report does not output the same results as shown in preview mode, which is to move the position of a check box based on a field value (see...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
by: icetalks | last post by:
have a look at this code , its for logging the user in after checking his UserName and Password. dim check as boolean = false ... ... If txtUserName.Text.Length = 0 And txtPass.Text.Length =...
5
kirubagari
by: kirubagari | last post by:
I want to check the arrangement of data in this order from byte 49 to mFile size(END OF FILE). 04 FF _ _ _ _ _04 FF _ _ _ _ 04 FF _ _. _ __ 04 FF _ _ _ _ 04 FF _ _ _ _ 04 FF Actually the values...
61
by: warint | last post by:
My lecturer gave us an assignment. He has a very "mature" way of teaching in that he doesn't care whether people show up, whether they do the assignments, or whether they copy other people's work....
2
by: LilMeechc20 | last post by:
Hello, I have a group assignment that I have to do. We have to write a Tic Tac Toe game. One person in my group has managed to write the code for a multiplayer (human -vs- human) game and I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.