select statement error

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2008
Posts: 53
Reputation: smile4evr is an unknown quantity at this point 
Solved Threads: 2
smile4evr's Avatar
smile4evr smile4evr is offline Offline
Junior Poster in Training

select statement error

 
0
  #1
Sep 18th, 2008
Hi all... please help me with this code... i hv retrieved the id of the employee from the login n stored it as a lable in my form- logid but now with respect to that i want to get the employee name... please help very urgent!!

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim rs As adodb.Recordset
  2. Dim getname As String
  3. getname = "SELECT E_name FROM Employee_Details WHERE E_ID ='" & logid.Caption & "'"
  4. rs.Open getname, CN
  5.  
  6. logname.Caption = rs.Fields(0)

the error msg shown is "object variable or with block variable not set."
please help its very urgent!
thanx!
-smile4evr!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 115
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: select statement error

 
0
  #2
Sep 18th, 2008
There are a few points that could cause error:
- change
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim rs As adodb.Recordset
to
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim rs As New adodb.Recordset
- make sure that CN is not nothing eg. you do have a valid connection object
- your query may return empty recordset. Haven't dealed with these for a long time but check that
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. rs.Fields(0)
is not nothing. I mean that rs is not nothing.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,149
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 132
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: select statement error

 
0
  #3
Sep 20th, 2008
byusing

Dim rs As new adodb.Recordset

your problem is solved.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 53
Reputation: smile4evr is an unknown quantity at this point 
Solved Threads: 2
smile4evr's Avatar
smile4evr smile4evr is offline Offline
Junior Poster in Training

Re: select statement error

 
0
  #4
Sep 21st, 2008
thnakx a lot!... it is solved...!
its working now!
tc!
n good day!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 769 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC