retrieving row with reference of Null value

Reply

Join Date: Jan 2009
Posts: 14
Reputation: devilz is an unknown quantity at this point 
Solved Threads: 0
devilz devilz is offline Offline
Newbie Poster

retrieving row with reference of Null value

 
0
  #1
Feb 21st, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: retrieving row with reference of Null value

 
0
  #2
Feb 21st, 2009
Hi

Use
  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
KSG
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC