app_code method cannot be access

I try to use the methods class from app_code, by using
Item.Methods.PurchaseItem
but failed
then i try to remove the namespace in methods.cs, also failed.

also notice that the DataSet , SqlDataAdapter in App_Code do not change colour.
Methods.cs (App_Code)
--------------------
namespace Item
{

    public class Methods
    {

        public Methods()
        {

        }

        private static string connstring = "Data Source=123\\SQLEXPRESS;Initial Catalog=productdb;User Id=xx;Password=xxx;";

        #region PurchaseItem

        public static string PurchaseItem(string itemname, int quantity, DateTime dt)
        {
            using (SqlConnection sqlconn = new SqlConnection(connstring))
            {

                DataSet dsItem = new DataSet();

                string strSQL = "Select * from Item where ItemName = '" + itemname + "'";
                SqlDataAdapter adapter = new SqlDataAdapter(strSQL, sqlconn);
                adapter.Fill(dsItem);

Open in new window

LVL 1
doramail05Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Albert Van HalenAnalyst developerCommented:
Make your class static : public static class Methods.
You can loose the default constructor ( public Methods() {} )
0
doramail05Author Commented:
i switched to WebSite template instead of WebApplication,
the colour of DataSet, SqlDataAdapter changed,
but still cannot access App_Code methods.
0
TeazerMDCommented:
Try adding this next to the rest of the usings:
using Item;

If this dosen't help - what does Intellisense tell you? Does it see this Namespace->Class->Method?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

doramail05Author Commented:
AlbertVanHalen & TeazerMD:

tried but cannot
0
doramail05Author Commented:
Intellisense sense here :

namespace Item
{
    public partial class Purchase : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Item.Purchase < --
        }
    }
}
0
TeazerMDCommented:
protected  void Page_Load(object sender, EventArgs e)
        {
            Methods.PurchaseItem(...);
        }
0
doramail05Author Commented:
yea,
that is what im trying to achieve,

could not find Methods in intellisense totally.
0
TeazerMDCommented:
Too bad.
I can help you further only if you are willing to supply the source project.
0
doramail05Author Commented:
theres an error trying to upload project file with .aspx extension, so i removed them, you can add them back easily.
Methods.cs (App_Code)
----------
public class Methods
    {

        public Methods()
        {

        }
        ...

Purchase.aspx.cs
----------------
public partial class Purchase : System.Web.UI.Page
{
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
}

Open in new window

WebSite2.zip
0
TeazerMDCommented:
Ok, your problem is that the "Methods.cs" is located in the App_Data instead of App_Code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
doramail05Author Commented:
o.O !  
ok thanx for that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.