Return value from access db
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
My database is set up like this
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:
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.
strSQL = "SELECT ([LocationID]) FROM [Locations] LIMIT 1 WHERE
([Occupied] = FALSE')"
I hope this made some sort of sense.
Thank you so much in advance for any help, it would be greatly appreciated.
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.
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.
By Dark Rain in forum Java
Last Post: 09-30-2005, 06:42 PM
By Whitewolf in forum Java
Last Post: 05-12-2002, 10:16 PM
By Nate in forum Database
Last Post: 05-09-2001, 10:04 AM
By Todd B - Agendum Software in forum vb.announcements
Last Post: 12-20-2000, 12:22 PM
By Marie in forum Database
Last Post: 11-20-2000, 05:37 AM
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