The type initializer for 'tags' threw an exception??

Hello

I get the following error... 

The type initializer for 'tags' threw an exception.

Does anyone who what this mean, or what might be causing this?

Heres the code on the page giving the error...

protected void Page_Load(object sender, EventArgs e)
    {
        WebUsers user = new WebUsers();

        if (!this.IsPostBack)
        {
            if (Session["user"] != null)
            {
                 user = (WebUsers)Session["user"];
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }

       // string grouptype = Request.QueryString["mygrouptype"];
        DataSet dst = new DataSet();
        dst = tags.TagsByGroup(user.ID.ToString()); // gives the error on this line

        GridView1.DataSource = dst;
        GridView1.DataBind();  
    }

And heres the method...

    public static DataSet TagsByGroup( string user)
    {
        SqlCommand cmd = new SqlCommand("SELECT	N.[Title], N.[Description], N.[Date_created], N.[User_ID], N.[Group_ID], N.[Date_updated], N.[gps_long], N.[Photo], N.[Tags_ID], N.[image] FROM	[TG_Tags_Table] AS N INNER JOIN [TG_Web_Users] AS U ON U.[User_ID] = N.[User_ID]INNER JOIN [TG_User_Groups] AS G ON G.[Group_ID] = N.[Group_ID] WHERE	N.[User_ID] = @user", conn);
        //SqlCommand cmd = new SqlCommand("select * from dbo.ImportedCashins where USsurname =@USsurname", conn);
        //cmd.Parameters.Add(new SqlParameter("@group_class", group_class));
        cmd.Parameters.Add(new SqlParameter("@user", user));
        DataSet dst = new DataSet();
        SqlDataAdapter dtr = new SqlDataAdapter(cmd);
        dtr.Fill(dst);
        return dst;
    }

 Anybody know what I'm doing wrong?

Thanks

 

0
fogofogo
11/20/2007 10:01:32 PM
asp.net.getting-started 91979 articles. 2 followers. Follow

4 Replies
414 Views

Similar Articles

[PageSpeed] 24

Could you post a copy of the error message please?

0
Codehat
11/20/2007 11:13:48 PM

Are you certain that the query is valid? 

Were it me I'd start by stepping through TagsByGroup, if I could. That would allow you to see exactly which line is failing.


This is the part where I politely request you to mark my response as the Answer, under the pretense that doing so will greatly help the community, blah, blah...
When in actuality I'm singlely intent upon the wopping 10 points that I'll receive!
... Oops, was that my outloud voice? ;)
0
tysonh28
11/20/2007 11:23:23 PM
Where is "tags.TagsByGroup("? You didn't post the code for it. Does it have a constructor? Is it a static or an instance class? It seems you aren't even getting into the TagsByGroup method.
[C# MVP]
Unblog|WebSite|IttyUrl
0
pbromberg
11/21/2007 12:52:50 AM

Made a silly mistake in the connection string! sorry for wasting your time.

0
fogofogo
11/21/2007 8:22:03 AM
Reply:

Similar Artilces:

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

'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   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 ...

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

TypeInitializationException: The type initializer for 'clGeneral' threw an exception.
Okay Here is what I did, I have done this 2 previous projects and it worked flawlessly.  It works on my local machine, but when I deploy it throws the above exception.  this project and the last project are hosted by the same company and are set-up the same (I think - default) I have a seperate class called clGeneral located in teh app_code directory. the clSecured is also located there.  The first class is nothing more than defining common variables like database connections and things like that.  The second I use to encode and decode items that I want to stor...

The type initializer for 'BLL.Customer' threw an exception.
What does this error mean??? No clue.........   In .NET, you can have instance constructors and you can also have a static constructor. The static constructor is used to initialize static variables or do other one-time setup for all instances of a class, usually. Static constructors are also called type initializers, and will be called before the first instance of the class is constructed (it appears to usually happen when you first call a method that needs to know about the type). To see the code that is throwing an exception, look at the code for the class mentioned. In C#, look f...

Unit test causes exception "The type initializer for 'XXX' threw an exception" when running code which accesses appSettings of the webconfig
I have a method which I want to unit test, the code inside that method accesses the appSetting to get the connectionString : System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString(); this piece of code works fine , but when  I m doing the unit test to test the method, the above line gives the below exception :MyMethod threw exception:  System.TypeInitializationException: The type initializer for 'XXX' threw an exception. --->  System.NullReferenceException: Object reference not set to an instance of an object..  ...

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception
Hi,All of a sudden I started getting this nasty exception all over the place:The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception. Some relevant observations:* The error started occuring a few hours after the last deployment to the live server, not immediately after. So it basically started occuring of its own accord.* We have recently moved to a new host (a VPS). The error only occurs on that server, not our local server nor at the old host's (which was a shared environment).* The problem is basically the same as this guys:http://w...

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.
I get this stacktrace at my ExceptionManager. It is caught in the Global.asax, so the exception is unhandled by my code :( We have many visitors and customers. This error occurs at least once a week, and all websites in the same pool are down. Only solution for now is to reset the pool when the error occurs. I know there are more topics on this, and I know MicroSoft is aware of the bug but does not know what to do about it. The bug will still be in the 3.5 release. If anybody has a work around for the fix, or a solution which is acceptable and avoids my customers and visitors ...

'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"/>...

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
 Hi all,When i run my project on my own computer, it works fine. But when i deploy it to server, it gives me this error. I can run my other dts and sp, but i get this error on this.. The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. I googled it but could not find a solution. How can i solve this problem?  Hello sourvil, I'm not sure what the problem is. The following thread explains how you can find out more about the error that is reported: http://blogs.infosupport.com/martijnb/archive/2006/01/27/3582.aspx Jeroen Molenaar.----...

The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.
Hi, We have an application developed using VS2002 and .NET 2002 Crystal reports. when this application is deployed on Win 2003 32 bit machine  it worked fine, but when deployed on windows 2003 64 bit machine, crystal reports are not opened. Replaced .NET 2002 Crystal reports with crystal reports 11. Problem still persists. It is giving exception as "The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.".   Can anyone help me on this.   Hi there, Me too, I encounter the same problem....

The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception.
Hello,I am using UDB  Database ( IBM DB2 9.1) with ASP.Net. I am inserting data in DB2 database!When I run my web site in Visual Studio 2008, I can connect with db2 database and successfully insert data!But when I deploy my web site locally in my IIS(After creating Virtual Directory) I receive following Error!   The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception. I uninstall/install Db2 Connect server 9.1, so many time but I am unable to find error!Please if you can help me!Thanks! EME Make sure you shut off VS.NET (no devenv.exe in t...

The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception
I have a VB .Net 2.0 web application which accesses oracle 8i database, the database was upgraded to 9i later on. The application worked fine just before the upgrade was made, but after the upgrade the application gives the following error. The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. I did a few searches in the oracle forums and downloaded and installed the Oracle Data Provider for .NET  version 9.2.0.4 form orcale website but the application still throws out the above exception. following is the stack trace of the application...

Web resources about - The type initializer for 'tags' threw an exception?? - asp.net.getting-started

Resources last updated: 12/6/2015 3:51:26 PM