Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 9th, 2008, 10:17 AM
Authorized User
 
Join Date: Jul 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default AccessDatasource.InsertParameters

Hi everyone im trying to save a check box value into an access database but it issues an exception saying that there's data type mismatch on this boolean field "AccessDataSource1.InsertParameters("status").Defa ultValue = True". Anybody help i don't know whether to convert it or do what pls help?

supertedz
__________________
supertedz
 
Old October 9th, 2008, 04:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there... access uses 0 and 1, (or 0 and -1) for boolean values, you should transform it to the correct one...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 9th, 2008, 07:13 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Look here:
http://msdn.microsoft.com/en-us/libr...aultvalue.aspx

The type of DefaultValue is *always* String, no matter what the data type of the actual parameter is.

So you *MUST* supply a String as the value, not a boolean or (as gbianchi suggested) an integer.

So you could do either
    AccessDataSource1.InsertParameters("status").Defau ltValue = "True"
or, if your intended value is actually a variable with actual value known only at run time,
    AccessDataSource1.InsertParameters("status").Defau ltValue = CType(someBooleanVariable,String)
or, since this is VB code,
    AccessDataSource1.InsertParameters("status").Defau ltValue = CStr(someBooleanVariable)

Yes, you could also use
    AccessDataSource1.InsertParameters("status").Defau ltValue = "-1"
But that's only because Access, in common with VB, returns -1 if you do CINT(True) and can, similarly, do CBOOL(-1) to produce a boolean True.

Personally, I'd be more "correct" and stick with either "True" or CTYPE(xxx,String) or CStr(xxx)
 
Old October 9th, 2008, 09:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

thanks for clarifying it old pedant...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
set accessdatasource.connectionstring yukijocelyn ASP.NET 2.0 Basics 0 September 12th, 2007 02:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.