Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...ERROR ->YourCompany.Modules.GuestBook.DataProvider.Instance()ERROR ->YourCompany.Modules.GuestBook.DataProvider.Instance()' is a 'method', which is not valid in
Previous
 
Next
New Post
7/18/2006 7:55 AM
 
i have 4 file :
DataProvider.CS
SQLDataProvider.CS
GuestBookControler.CS
GuestBookInfo.CS


DataProvider.CS :
using System;
using DotNetNuke;
using System.Data;

using DotNetNuke.Framework;

namespace YourCompany.Modules.GuestBook
{  
    public abstract class DataProvider
    {

    #region Shared/Static Methods

        // singleton reference to the instantiated object
        private static DataProvider  objProvider = null;

        // constructor
        static DataProvider()
        {
            CreateProvider();
        }

        // dynamically create provider
        private static void CreateProvider()
        {
            objProvider = (DataProvider)Reflection.CreateObject("data", "YourCompany.Modules.GuestBook", "");
        }

        // return the provider
        public static  DataProvider Instance()
        {
            return objProvider;
        }

    #endregion

    #region Abstract methods
       
        public abstract void YourCompany_GuestBook_Insert(int ModuleId, string Name, string Email, string Message);
        public abstract IDataReader YourCompany_GuestBook_GetAll(int ModuleId);
        public abstract void YourCompany_GuestBook_Update(int ID, string Name, string Email, string Message, DateTime DateEntered);
        public abstract void YourCompany_GuestBook_Delete(int ID);           

    #endregion  
    }
}

SQLDataProvider.CS
using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Framework.Providers;

namespace YourCompany.Modules.GuestBook
{   
    public class SqlDataProvider : DataProvider
    {

    #region Private Members

        private const string ProviderType = "data";
        private const string ModuleQualifier = "YourCompany_";

        private ProviderConfiguration _providerConfiguration = ProviderConfiguration.GetProviderConfiguration(ProviderType);
        private string _connectionString;
        private string _providerPath;
        private string _objectQualifier;
        private string _databaseOwner;    
 
    #endregion

    #region Constructors
     
        public SqlDataProvider()
        {
            //Read the configuration specific information for this provider
            Provider objProvider = (Provider)_providerConfiguration.Providers[_providerConfiguration.DefaultProvider];

            //Read the attributes for this provider
            if ((objProvider.Attributes["connectionStringName"] != "") && (System.Configuration.ConfigurationManager.AppSettings[objProvider.Attributes["connectionStringName"]] != ""))
            {
                _connectionString = System.Configuration.ConfigurationManager.AppSettings[objProvider.Attributes["connectionStringName"]];
            }
            else
            {
                _connectionString = objProvider.Attributes["connectionString"];
            }

            _providerPath = objProvider.Attributes["providerPath"];

            _objectQualifier = objProvider.Attributes["objectQualifier"];

            if ((_objectQualifier != "") && (_objectQualifier.EndsWith("_") == false))
            {
                _objectQualifier += "_";
            }

            _databaseOwner = objProvider.Attributes["databaseOwner"];
            if ((_databaseOwner != "") && (_databaseOwner.EndsWith(".") == false))
            {
                _databaseOwner += ".";
            }
        }
   
    #endregion

    #region Properties

        /// <summary>
        /// Gets and sets the connection string
        /// </summary>
        public string ConnectionString
        {
            get {   return _connectionString;   }
        }

        /// <summary>
        /// Gets and sets the Provider path
        /// </summary>
        public string ProviderPath
        {
            get {   return _providerPath;   }
        }

        /// <summary>
        /// Gets and sets the Object qualifier
        /// </summary>
        public string ObjectQualifier
        {
            get {   return _objectQualifier;   }
        }

        /// <summary>
        /// Gets and sets the database ownere
        /// </summary>
        public string DatabaseOwner
        {
            get {   return _databaseOwner;   }
        }

    #endregion

    #region Private Methods

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the fully qualified name of the stored procedure
        /// </summary>
        /// <param name="name">The name of the stored procedure</param>
        /// <returns>The fully qualified name</returns>
        /// -----------------------------------------------------------------------------
        private string GetFullyQualifiedName(string name)
        {
            return DatabaseOwner + ObjectQualifier + ModuleQualifier + name;
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the value for the field or DbNull if field has "null" value
        /// </summary>
        /// <param name="Field">The field to evaluate</param>
        /// <returns></returns>
        /// -----------------------------------------------------------------------------
        private Object GetNull(Object Field)
        {
            return Null.GetNull(Field, DBNull.Value);
        }

    #endregion

    #region Public Methods       

        public override void YourCompany_GuestBook_Insert(int ModuleId, string Name, string Email, string Message)
        {
            SqlHelper.ExecuteNonQuery(ConnectionString, GetFullyQualifiedName("YourCompany_GuestBook_Insert"), ModuleId, Name, Email, Message);
        }

        public override void YourCompany_GuestBook_Delete(int ID)
        {
            SqlHelper.ExecuteNonQuery(ConnectionString, GetFullyQualifiedName("YourCompany_GuestBook_Delete"), ID);
        }

        public override IDataReader YourCompany_GuestBook_GetAll(int ModuleId)
        {
            return (IDataReader) SqlHelper.ExecuteReader(ConnectionString, GetFullyQualifiedName("YourCompany_GuestBook_GetAll"),ModuleId);
        }

        public override void YourCompany_GuestBook_Update(int ID, string Name, string Email, string Message, DateTime DateEntered)
        {
            SqlHelper.ExecuteNonQuery(ConnectionString, GetFullyQualifiedName("YourCompany_GuestBook_Update"), ID, Name, Email, Message, DateEntered);
        }       

    #endregion
    }
}

GuestBookInfo.CS
using System;
using System.Configuration;
using System.Data;

namespace YourCompany.Modules.GuestBook
{   
    public class GuestBookInfo
    {

    #region Private Members

        private int _ModuleId;
        private int _ID;
        private string _Name;
        private string _Email;
        private string _Message;
        private DateTime _DateEntered;

    #endregion

    #region Constructors
      
        public GuestBookInfo()
        {
        }

    #endregion

    #region Public Methods

        /// <summary>
        /// Gets and sets the Module Id
        /// </summary>
        public int ModuleId
        {
            get
            {
                return _ModuleId;
            }
            set
            {
                _ModuleId = value;
            }
        }

        /// <summary>
        /// Gets and sets the Id
        /// </summary>
        public int ID
        {
            get
            {
                return _ID;
            }
            set
            {
                _ID = value;
            }
        }

        /// <summary>
        /// gets and sets the Name
        /// </summary>
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        /// <summary>
        /// Gets and sets the Email
        /// </summary>
        public string Email
        {
            get
            {
                return _Email;
            }
            set
            {
                _Email = value;
            }
        }

        /// <summary>
        /// Gets and sets the Message
        /// </summary>
        public string Message
        {
            get
            {
                return _Message;
            }
            set
            {
                _Message = value;
            }
        }

        /// <summary>
        /// Gets and sets the Date when DateEntered
        /// </summary>
        public DateTime DateEntered
        {
            get
            {
                return _DateEntered;
            }
            set
            {
                _DateEntered = value;
            }
        }
    #endregion  
    }
}

GuestBookControler.CS
using System;
using System.Collections.Generic;
using System.Configuration;
using System.ComponentModel;
using System.Data;
using System.Xml;
using System.Web;
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Search;

namespace YourCompany.Modules.GuestBook
{   
    public class GuestBookController
    {  

    #region Public Methods  

        [DataObjectMethod(DataObjectMethodType.Insert)] public static void GuestBook_Insert(GuestBookInfo objTest)
        {
            DataProvider.Instance.YourCompany_GuestBook_Insert(objTest.ModuleId, objTest.Name, objTest.Email, objTest.Message); //(THIS IS MY ERROR)
        }

        [DataObjectMethod(DataObjectMethodType.Delete)] public static void GuestBook_Delete(GuestBookInfo objTest)
        {
           // DataProvider.Instance.YourCompany_GuestBook_Delete(objTest.ID);
        }

        [DataObjectMethod(DataObjectMethodType.Select)] public static List<GuestBookInfo> GuestBook_GetAll(int ModuleId)
        {
            return CBO.FillCollection<GuestBookInfo>(DataProvider.Instance().YourCompany_GuestBook_GetAll(ModuleId));
        }
 
        [DataObjectMethod(DataObjectMethodType.Update)] public static void GuestBook_Update(GuestBookInfo objTest)
        {
           //  DataProvider.Instance.YourCompany_GuestBook_Update(objTest.ID, objTest.Name, objTest.Email, objTest.Message, objTest.DateEntered);
        }

    #endregion  
    }
}


this is component of my dotnetnuke module...

when i type localhost/dotnetnuke_2 in my browser causes this error :

error CS0119: 'YourCompany.Modules.GuestBook.DataProvider.Instance()' is a 'method', which is not valid in the given context

can somebody help me???




 
New Post
7/18/2006 9:02 AM
 

You use the method Instance() as a property.

DataProvider.Instance.YourCompany_GuestBook_Insert(objTest.ModuleId, objTest.Name, objTest.Email, objTest.Message);

But it is a method. In VB.NET it could be called using “Instance” or “Instance()”syntax, but in C# it can be called only with “Instance()”syntax. Change your code with this:

DataProvider.Instance().YourCompany_GuestBook_Insert(objTest.ModuleId, objTest.Name, objTest.Email, objTest.Message);

 
New Post
7/18/2006 12:46 PM
 
thank for the reply answer....
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...ERROR ->YourCompany.Modules.GuestBook.DataProvider.Instance()ERROR ->YourCompany.Modules.GuestBook.DataProvider.Instance()' is a 'method', which is not valid in


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out