943,903 Members | Top Members by Rank

Ad:
Feb 21st, 2009
0

retrieving row with reference of Null value

Expand Post »
Can any one please help me?? Using VB 6.0 and Access DB.


Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ssql2 = "INSERT INTO JanuaryDay (JanRm_id) SELECT rmd_id FROM RmIdIndex WHERE rm_id= " & CLng(txtrostermid.Text)
  2.  
  3. rsName.Open ssql2, conName, adOpenDynamic, adLockOptimistic
  4.  
  5. rsmnth.Open "select * from JanuaryDay", conName, adOpenDynamic, adLockOptimistic
  6.  
  7. rsmnth.MoveFirst
  8. Do While Not rsmnth.EOF
  9. ‘here is the problem.
  10. If rsmnth("JanRm_id") = txtrmdid.Text And rsmnth("JanDate") = Null Then
  11. 'in DB JanRm_id(column) of JanuaryDay(table) will contain duplicate 'value. ‘That’s what after inserting data in JanRm_id I want to pick 'the row which ‘having data in JanRm_id and no data in JanDate, so 'that I can input data in ‘that specific row. Cannot use UPDATE 'command coz JanRm_id have duplicate ‘value.
  12. 'Same thing I did with number data type. Like:
  13.  
  14. 'ssql2 = "INSERT INTO UserOfTheMonth (emp_id) SELECT Emp_id 'FROM ‘users where Name='" & CboName.Text & "'"
  15.  
  16. ' rsName.Open ssql2, conName, adOpenDynamic, adLockOptimistic
  17.  
  18. 'rsmnth.Open "select * from UserOfTheMonth", conName, 'adOpenDynamic, ‘adLockOptimistic
  19.  
  20. 'rsmnth.MoveFirst
  21. 'Do While Not rsmnth.EOF
  22. 'If rsmnth("year") = 0 And rsmnth("emp_id") = TxtEmpId.Text Then
  23. 'txtrostermid.Text = rsmnth("rosterm_id")
  24. 'rsmnth.Fields("month").Value = Trim(Cbomnth.Text)
  25. 'rsmnth.Fields("year").Value = Val(Cboyear.Text)
  26. 'rsmnth.Update
  27. 'End If
  28. ' rsmnth.MoveNext
  29. ' Loop
  30.  
  31. 'Here year(column) of UserOfTheMonth having number data type. 'But above one (rsmnth("JanDate") = Null) is having Text data type.
  32. 'Vary new with VB6.0. Hitting my head to wall for the last 2 days.
  33. 'Can any one help me please
  34.  
  35. rsmnth.Fields("JanDate").Value = Trim(Label1.Caption)
  36. rsmnth.Fields("JanShift").Value = Trim(Combo1.Text)
  37. rsmnth.Update
  38. End If
  39. rsmnth.MoveNext
  40. Loop
  41. End If

regards
Reputation Points: 10
Solved Threads: 0
Newbie Poster
devilz is offline Offline
14 posts
since Jan 2009
Feb 21st, 2009
0

Re: retrieving row with reference of Null value

Hi

Use
VB Syntax (Toggle Plain Text)
  1. Dim sJanDate as String
  2.  
  3. 'Retrieve empty string if the record is null
  4. sJanDate = rsmnth("JanDate") & ""
  5.  
  6. 'Then check it
  7. If sJanDate = "" .... Then
  8. ....
  9. End if
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Deleting listview checked data using delete button
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: help my mshflexgrid1 did not update





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC