Last post Oct 26, 2008 04:16 PM by rocha_dk
Oct 26, 2008 09:20 AM|rocha_dk|LINK
As a follow up on my previous question:
I would like to know if any of you have an answer to the problem with the SqlCacheDependency throwing an System.NotSupportedException when trying to update using an AccessDataSource?
Oct 26, 2008 02:09 PM|Mikesdotnetting|LINK
Since the SqlCacheDependency is not supported by Access, any attempt to make use of it through an AccessDataSource control will result in a NotSupportedException:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.accessdatasource.sqlcachedependency.aspx. The mystery is why your code threw the exception. There's nothing obvious there, and at a guess, I doubt you have deliberately tried to get or
set the SqlCacheDependency anywhere else in code, so it has all the makings of a bug. Something's being exposed that shouldn't be.
Do you get this every time you try to run the page? Or just occasionally?
Oct 26, 2008 02:15 PM|rocha_dk|LINK
I get it everytime running the page, but other places in the code, where I do something similar, it doesn't occur. I'm quite new to .net, so I haven't set SqlCacheDependency anywhere :)
Oct 26, 2008 02:19 PM|Mikesdotnetting|LINK
OK. I figured as much :-)
Could you post the code for the entire page that throws the error, including code-behind? And point to which line casues the error.
Oct 26, 2008 03:33 PM|rocha_dk|LINK
This is the Pages-class' function save
It even returns true, but it if i look at the datasource, it contains the error and nothing is updated ?!?
the page class looks has the following properties:
Oct 26, 2008 04:02 PM|Mikesdotnetting|LINK
Right. The first thing I always check with Access INSERT and UPDATE statements is to see if the parameters are added to the command obejct in the same order as they appear in the SQL. In your case, the UpdateParameters are not. The first one you add is
@id, whereas the first one in the SQL Update statement is @name. Change the order that you add them to match that in the SQL and see if that fixes the problem. With OleDb, the position of the parameters is absolutely everything.
The second thing I recommend is to drop the use of the AccessDataSource control altogether. It's fine for quick and dirty work, and is supposed to save you loads of coding by allowing you to work declaratively. It was never intended to be instantiated
in code-behind. In the example above, it's not saving you any time really, and seems to be hiding errors. I suggest you get to grips with a plain ADO.NET approach:
Parameter Queries in ASP.NET with Access. You're most of the way there anyway.
Oct 26, 2008 04:16 PM|rocha_dk|LINK
Thank you very much.. the parameters in the right order-thingie worked :)
I'll have a look at the ADO.NET approach!
Again thank you very much for the help, it's really appreciated!!