Answered by:
YES/NO field in access---what data type?

Question
-
User-911157248 posted
I am trying to update via sql involving ms access yes/no data type but I am unsure of what type to delare the corresponding parameter to do the updating?
I have tried this:
AccessDataSource1.UpdateParameters.Add("zanswer", TypeCode.boolean)
AccessDataSource1.UpdateParameters("zanswer").DefaultValue = True
Data type mismatch in criteria expression.
Friday, March 18, 2011 3:04 PM
Answers
-
User-1199946673 posted
After trial and error fiddling with this, it seems only to accept -1,0 for values.
I you say so! I just did a simple test, "True" or "False" work perfectly.....
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 22, 2011 1:59 PM
All replies
-
User-1179452826 posted
The database datatype should be bit. If so, you'll be able to pass true or false.
Friday, March 18, 2011 3:08 PM -
User-911157248 posted
MS access defines it as YES/NO. so what to do?
Friday, March 18, 2011 3:12 PM -
User-1199946673 posted
The DataType of the DefaultValue Property of a DataSource Parameter is a string, so you need to pass a string that represents a boolean:
AccessDataSource1.UpdateParameters("zanswer").DefaultValue = "True"
Friday, March 18, 2011 3:14 PM -
User-911157248 posted
Access will be ok with a string in a Y/N field?
Friday, March 18, 2011 3:20 PM -
User-1199946673 posted
Access will be ok with a string in a Y/N field?
You don't understand what I said. I said that the DataType of the DefaultValue Property is a string. That means that a yes/no field in the database is "True" or "False", an integer is "1", "2", "3", ....., and a date is "3/18/2010".
All string Values that represent a specific datatype....
Friday, March 18, 2011 4:48 PM -
User3866881 posted
Yes, DefaultValue is a type of String. So you should use quote.
And now you can also have a try:
AccessDataSource1.UpdateParameters("zanswer").DefaultValue = "Yes/No";
Monday, March 21, 2011 12:11 AM -
User-911157248 posted
After trial and error fiddling with this, it seems only to accept -1,0 for values.
Tuesday, March 22, 2011 11:26 AM -
User-1199946673 posted
After trial and error fiddling with this, it seems only to accept -1,0 for values.
I you say so! I just did a simple test, "True" or "False" work perfectly.....
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 22, 2011 1:59 PM