'ds.SqlCacheDependency' threw an exception of type 'System.NotSupportedException'

Hi guys,

As a follow up on my previous question: http://forums.asp.net/t/1336003.aspx 
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?

Thanks :)

/Ole

 

0
rocha_dk
10/26/2008 1:20:36 PM
asp.net.access-datasource 4679 articles. 0 followers. Follow

6 Replies
441 Views

Similar Articles

[PageSpeed] 24

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?

 

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
10/26/2008 6:09:15 PM

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 :)

 

0
rocha_dk
10/26/2008 6:15:58 PM

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.

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
10/26/2008 6:19:38 PM

Ok :)

 This is the Pages-class' function save

public bool Save()
{
  bool returnBool = false;
  AccessDataSource ds = new AccessDataSource();
  ds.DataFile =
"~/App_Data/db.mdb";
  ds.InsertCommand =
"INSERT INTO [pages] ([name], [text], [text_de], [text_en], [text_box], [text_box_de], [text_box_en]) VALUES (@name, @text, @text_de, @text_en, @text_box, @text_box_de, @text_box_en);";
  ds.UpdateCommand =
"UPDATE [pages] SET [name] = @name, [text] = @text, [text_de] = @text_de, [text_en] = @text_en, [text_box] = @text_box, [text_box_de] = @text_box_de,   [text_box_en] = @text_box_en WHERE [ID] = @id";
  if (Id != null)
  {
    ds.UpdateParameters.Add(
"id", this.id.ToString());
    ds.UpdateParameters.Add(
"name", this.Navn);
    ds.UpdateParameters.Add(
"text", this.Text);
    ds.UpdateParameters.Add(
"text_de", this.Text_de);
    ds.UpdateParameters.Add(
"text_en", this.Text_en);
    ds.UpdateParameters.Add(
"text_box", this.Boxtext);
    ds.UpdateParameters.Add(
"text_box_de", this.Boxtext_de);
    ds.UpdateParameters.Add(
"text_box_en", this.Boxtext_en);
    try
    {
      ds.Update();
      returnBool =
true;
    }   
    catch
    {
      returnBool =
false;
    }
  }
  else
  {
    ds.InsertParameters.Add(
"name", this.Navn);
    ds.InsertParameters.Add(
"text", this.Text);
    ds.InsertParameters.Add(
"text_de", this.Text_de);
    ds.InsertParameters.Add(
"text_en", this.Text_en);
    ds.InsertParameters.Add(
"text_box", this.Boxtext);
    ds.InsertParameters.Add(
"text_box_de", this.Boxtext_de);
    ds.InsertParameters.Add(
"text_box_en", this.Boxtext_en);
    try
    {
      ds.Insert();
      returnBool =
true;
    }
    catch
    {
      returnBool =
false;
    }
  }
  ds.Dispose();
  return returnBool;
}

 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:

int id
string name
string text
string text_box
string text_de
string text_box_de
string text_en
string text_box_en

 

0
rocha_dk
10/26/2008 7:33:31 PM

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.

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
10/26/2008 8:02:00 PM

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!!

0
rocha_dk
10/26/2008 8:16:24 PM
Reply:

Similar Artilces:

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

Length = 'requestStream.Length' threw an exception of type 'System.NotSupportedException'
 I cannot figure out why when I expand the requestStream variable that I see that error.  Here's my code:   ... request.Timeout = 30000; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; // write data to stream byte[] requestBytes = Encoding.UTF8.GetBytes(request.ToString()); using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(reque...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

'''
Name: L Lachowsky Email: e2brutus_10atyahoodotcom Product: Firefox Summary: ''' Comments: why duddn this surprise me... I change default server from IE to Mozilla, and then i get error messages. well, shud I decide to not get on my computer with Mozilla..or shud I risk security breeches with IE....hmmm at least i can get on the internet with IE Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this fee...

Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'
Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error... Dim EmailBodyTxt As New StringBuilder EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td>...

'Sybase.Data.AseClient.AseConnection.DriverVersion' threw an exception of type 'System.TypeInitializationException'
'Sybase.Data.AseClient.AseConnection.DriverVersion' threw an exception of type 'System.TypeInitializationException' This is an error which I am getting while instantiating AseConnection. Can I get help on this exception. I am using C# in Visual Studio 2005. I checked the version in the C:\Program Files\Sybase\OC12_5_1\ADO.NET\dll folder of Sybase.Data.AseClient.dll and sybdrvado11.dll and copied these dlls to my application's bin folder. The versions are the same. Still I am getting the above exception. Whats this code look like? Are you sure both DLLs are sa...

Cannot convert type 'type' to 'type'
I am learning all of this, so I am still fresh, so please bear with me :)I have a page that has some txtboxes in it, simple registration form, and I have a button that will save those txt boxes to the db. I am using:- I am using Visual Web Developer 2008 Express Edition- C# When I try to compile the project I get error: Cannot convert type 'System.Web.UI.WebControls' to 'String' This is content of my web.config    <profile> <properties> <add name="FirstName"/> <add name="LasttName"/>...

Operator '=' is not defined for type 'Char' and type 'Boolean'.
Hello, In my application when i click the button i'm getting this " Operator '=' is not defined for type 'Char' and type 'Boolean'. " But when i test it locally there is no problem at all!!!! Please tell me why this error is occuring...Thanks SwapnaPlease click "mark as answer" if this post helped you. swapnasamsonvarkey: Hello, In my application when i click the button i'm getting this " Operator '=' is not defined for type 'Char' and type 'Boolean'. " But when i test it lo...

Operator '*' is not defined for type 'DBNull' and type 'Decimal'.
 I am getting an error from the following line   <asp:Label ID="Label1" runat="server" Text='<%# String.Format("{0:C}", Eval("ProductQty") * Eval("Price"))   %>' ></asp:Label> I think I may need to convert/define the Variables but not quite sure how to do it. Any help would be great. it's not a matter of converting...its the fact that the value from the DB is Null... You'll have to wrap an IF check around it or change your query to return 0 instead of Null. If the field ...

System.Net.Mail is giving error CS0029: Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'
I'm getting an error while trying to use the wizard to create a form and than pass it the vaibles to Mail. Any help would be much appreciated. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try {   message.From = txtEmail.Text; message.To.Add("admin1@yoursite.com"); message.Subject = "Feedback"; message.CC.Add("admin1@yoursite.com"); message.CC.Add("admin2@yoursite.com"); message.IsBodyHtml = false; message.Body = txtMessage.Text; smtpClient.Send(message); lblStatus.Text = "Email successfully sent."; } catch (Exception ex) { lbl...

'or' or 'union'
Hello I was just wondering, in general what is better to use, an 'or' clause in a select or a 'union' to join two selects together. Do both statements create work tables? Many thanks Alex I think OR will be better than union. because suppose u have 3 tables and using OR u can join table a and table b and table c so each table will have only one read. but using union you will join table a and table b and in another query of union u will use table (a or b) and table c so ur one read is more in union . Ramdas Alex Cheung wrote: > Hello > >...

'b'..'a'
Hello. I'm using defferent 5.6.0's for Win32. I wonder wheter following behaviour is intentional or not: d:\>perl -e "print 'b'..'c'" bc d:\>perl -e "print 'b'..'a'" bcdefghijklmnopqrstuvwxyz I expected empty list in latter case, like in perl -e "print 'bb'..'a'" <!ENTITY Vadim REALLIFE "Vadim V.Konovalov, St.Petersburg, Russia"> &Vadim; On Wed, Sep 20, 2000 at 03:14:41PM +0400, Konovalov, Vadim wrote: > Hello. > > I'm using defferent 5.6.0'...

Web resources about - 'ds.SqlCacheDependency' threw an exception of type 'System.NotSupportedException' - asp.net.access-datasource

Resources last updated: 12/15/2015 4:13:18 AM