checkbox problem

jumper

New member
Joined
Apr 28, 2005
Messages
4
Programming Experience
Beginner
high there

I have a database is access and a project in VisualBasic.
Now I want to update the yes/no (checkbox) field in table tbl_verhuurd (dutch for tbl_rental)

But I keep getting errors...
VB.NET:
intfilm = 4 
 
 
Dim db_file As String 
Dim statement As String 
Dim conn As adodb.Connection 
Dim Rs As adodb.Recordset 
 
' Get the data. 
db_file = App.Path 
If Right$(db_file, 1) <> "\" Then db_file = db_file & _ 
"\" 
db_file = db_file & "db1.mdb" 
' Open a connection. 
Set conn = New adodb.Connection 
conn.ConnectionString = _ 
"Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
"Data Source=" & db_file & ";" & _ 
"Persist Security Info=False" 
conn.Open 
 
' Select the data. 
'enkel de NIET verhuurde films tonen 
statement = "select verhuurd, id from tbl_verhuurd where id=" & intfilm 
 
' Get the records. 
Set Rs = conn.Execute(statement, , adCmdText) 
 
'check the checkbox in the table
Rs!verhuurd = -1
Rs.Update 
 
' Close the recordset and connection. 
Rs.Close 
conn.Close

Is it that hard to update a checkbox? all the other fields worked just fine.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,335
Location
Sydney, Australia
Programming Experience
10+
You should set an Access database Yes/No field to True or False in VB.NET, regardless of how it is displayed in Access itself. Despite the newbie-friendly name of Yes/No, this type of field is just a Boolean. I would also recommend using types from the System.Data.OleDb namespace to interact with an Access database.
 
Top Bottom