DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Return value from access db

    Hi there,

    I am stuck with returning a record from an Access database using VB.NET

    I want to return a value from the database but I am having a bit of trouble with the method on how to do it, done some searching but not sure if I am looking for the right thing.

    Here is an example:

    I have Locations which I am using for a stock control system and I have a set of locations such as

    A1
    A2
    A3
    A4
    etc...

    My database is set up like this

    LocationID Occupied
    A1 True
    A2 False
    A3 False
    A4 False

    I want to be able to run a query which returns the value of a Location which Occupied = False and

    tell me the location i.e A2, A3 etc, but only want it to return 1 record as I want it to tell me the Location and then when confirmed by the user and its booked in I want to change the value to True.

    I was thinking something along the lines of:
    Code:
    strSQL = "SELECT ([LocationID]) FROM [Locations] LIMIT 1 WHERE
    ([Occupied] = FALSE')"
    and then want to be able to tell me which LocationID it has selected and return that LocationID to the user but I am unsure of the method on how to do this.

    I hope this made some sort of sense.

    Thank you so much in advance for any help, it would be greatly appreciated.

  2. #2
    Join Date
    Jul 2012
    Posts
    1

    Thumbs up Re:

    You can use the OldeDBCommand and related classes to execute the required Query. Your query is correct. You will get the single locationID thru that Query. display this result to user on the screen thru any GUI controls. On click event of the Confirm button you can execute the Update Query like this.

    Update Locations
    Set Occupied = true
    Where LocationID = "SelectedLocation"

    Where seletedLocation will be the location returned by your query.

    Let me know if you still have any problem .
    Last edited by Hack; 08-03-2012 at 11:42 AM.

Similar Threads

  1. Why is this in the console?
    By Dark Rain in forum Java
    Replies: 8
    Last Post: 09-30-2005, 06:42 PM
  2. Return a Vector
    By Whitewolf in forum Java
    Replies: 6
    Last Post: 05-12-2002, 10:16 PM
  3. Access to SQL server
    By Nate in forum Database
    Replies: 29
    Last Post: 05-09-2001, 10:04 AM
  4. Replies: 0
    Last Post: 12-20-2000, 12:22 PM
  5. Replies: 0
    Last Post: 11-20-2000, 05:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links