Click here to Skip to main content
14,328,713 members
Rate this:
Please Sign up or sign in to vote.
Hey there, so basically I have a database with a few tables and one of those tables has a particular column, called "Shift" and the first row/cell of that column may have values 1 or 2.

What I'm trying to get my program to do is to connect to the database and if the value on that row is 1, then something is gonna happen, if the value is 2, something else is gonna happen.

So basically I'm trying to read the value of a cell in an Access database and do something according to what that value is.

This should be very easy to do but I'm a noobie... =(

Here's a part of my code, and one of my wrong attempts, you should be able to understand what I'm trying to do from this:

Provider = "Provider=Microsoft.ACE.OLEDB.12.0;"
Source = "Data Source = Database.accdb"

Connection.ConnectionString = Provider & Source

Connection.Open()

'My wrong attempt at doing this:
If SQL = "Shift FROM Schedule WHERE ID = 1;" = 1 Then
    '.....
    '.....
ElseIf SQL = "Shift FROM Schedule WHERE ID = 1;" = 0 Then
    '....
    '.....
Else
    MsgBox("error")
End If

Connection.Close()
Posted
Updated 9-Dec-11 6:53am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You need to execute the query, get the result back from the database and compare it against 1.
At the moment you are actually just comparing the string value.

This[^] is a simple example that might help you proceed further.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100