Click to See Complete Forum and Search --> : Adding and Retriving Bit values froma database


scouse
11-16-2007, 04:15 AM
Hey,

I've got a check box like the following:


<input type="checkbox" name="activate_article" value="1">


I then retrieve this value from the form with this:


strActivate = DbInsert(request("activate_article"))
if strActivate = "" then
strActivate = 0
end if


and then enter it into the SQL database into a field that has a BIT field type. This works fine.

I then try to retireve this value later to check/uncheck the checkbox depending on whether the user had checked/unchecked it.

I use this to retrieve from the recordset:


activate_article = trim(RS("activate_article"))


I then try to check the value of "activate_article" to determine the state of the checkbox using this:


line 761: if activate_article = 1 then
line 762: article_check = "checked"
line 763: end if


BUT this brings up this error:

Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: "True"]'
Line 761


I've not really worked much with BIT values so might just be making a simple mistake.

Any help would be great

Cheers

gil davis
11-16-2007, 08:25 AM
Why do you use Trim() on a bit field?

scouse
11-16-2007, 08:32 AM
erm, I didn't realise you weren't meant too :o

gil davis
11-16-2007, 12:02 PM
erm, I didn't realise you weren't meant too :o
So, I take it that removing it didn't fix the problem?

scouse
12-19-2007, 10:17 AM
Hi,

Sorry for late reply, been manic.

Yes that did seem to do the trick. thanks very much!