Please Check the code

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • QVeen72
    replied
    Hi,

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

    REgards
    Veena

    Leave a comment:


  • Vbbeginner07
    replied
    Originally posted by QVeen72
    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

    Leave a comment:


  • QVeen72
    replied
    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

    Leave a comment:


  • Vbbeginner07
    replied
    Originally posted by QVeen72
    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:
    [code=vb]
    rs.Open "select * from empdetail Where ID='" & txtid.Text & "'", conn, adOpenStatic, adLockOptimisti c
    If rs.EOF Then
    conn.BeginTrans
    conn.Execute "insert into empdetail(id,na me,whours,rate, otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
    conn.CommitTran s
    MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
    Else
    'ID Found In DB (Duplicate)
    MsgBox "Duplicate Entry"
    End If
    [/code]
    Nick
    Last edited by debasisdas; Feb 14 '08, 11:45 AM. Reason: added code=vb tags

    Leave a comment:


  • Vbbeginner07
    replied
    Originally posted by debasisdas
    try to use this

    [code=vb]
    rs.Requery
    [/code]
    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

    Leave a comment:


  • QVeen72
    replied
    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

    Leave a comment:


  • debasisdas
    replied
    try to use this

    [code=vb]
    rs.Requery
    [/code]

    Leave a comment:


  • mafaisal
    replied
    Hello
    try this
    Code:
    if Rs.state =1 then rs.close
    Originally posted by Vbbeginner07
    not two recordsets are opened at the sametime,n tell me how a sql recoredset be refreshed???tel l me the code to refersh
    NICK

    Leave a comment:


  • Vbbeginner07
    replied
    Originally posted by debasisdas
    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???tel l me the code to refersh
    NICK

    Leave a comment:


  • debasisdas
    replied
    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.

    Leave a comment:


  • Vbbeginner07
    replied
    Originally posted by Vbbeginner07
    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

    Leave a comment:


  • Vbbeginner07
    replied
    Originally posted by debasisdas
    try using this

    [code=vb]
    conn.begintrans
    conn.Execute "insert into empdetail(id,na me,whours,rate, otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
    conn.commitrans
    [/code]
    Debasis not working........ .
    Please go through my code n please suggest......
    Nick

    Leave a comment:


  • debasisdas
    replied
    try using this

    [code=vb]
    conn.begintrans
    conn.Execute "insert into empdetail(id,na me,whours,rate, otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
    conn.commitrans
    [/code]

    Leave a comment:


  • Vbbeginner07
    started a topic Please Check the code

    Please Check the code

    THE FOLLOWING CODE INSERTS A PARTICULAR DATA INTO THE recordset WHICH IS THE FIRST FORM!!!
    [code=vb]
    rs.Open "select * from empdetail Where ID='" & txtid.Text & "'", conn, adOpenStatic, adLockOptimisti c
    If rs.EOF Then
    conn.Execute "insert into empdetail(id,na me,whours,rate, otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
    MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
    Else
    [/code]
    THE SECONF FORM CONTAINS A LISTVIEW ,WHICH HAS TO DISPLAY THE RECORDS saved through FORM 1
    [code=vb]
    rs.Open "select distinct empdetail.name, saldetail1.id from empdetail,salde tail1 where saldetail1.id = empdetail.id", conn, adOpenStatic, adLockOptimisti c
    If Not rs.EOF Then
    rs.MoveFirst
    Do While Not rs.EOF
    With ListView1
    Set lvitem = ListView1.ListI tems.Add(, , rs!id)
    lvitem.SubItems (1) = rs!Name
    rs.MoveNext
    End With
    Loop
    End If
    rs.Close
    Set rs = Nothing
    ListView1.Refre sh
    ListView2.Refre sh
    [/code]
    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!!!
    Last edited by debasisdas; Feb 13 '08, 08:50 AM. Reason: added code=vb tags
Working...