Accecced with an instance reference.

lblLoginCounts.Text = user.GetUserLoginCounts(Int32.Parse(Page.User.Identity.Name)).ToString();
Error      1      Static member 'UserDB.UsersDB.GetUserLoginCounts(int)' cannot be accessed with an instance reference; qualify it with a type name instead      D:\Inetpub\wwwroot\omegalove\Default.aspx.cs      32      43      D:\...\omegalove\

 public static int GetUserLoginCounts(int userID)
        {
            // create data object and params
            SqlDataReader dataReader = null;
            int iCounts = 0;

            // create params for stored procedure call
            Database data = new Database();

            SqlParameter[] prams =
                  {                    
                        data.MakeInParam("@iUserID" ,SqlDbType.Int, 4, userID)                        
                  };

            // run the stored procedure
            data.RunProc("prcUserGetLoginCounts", prams, out dataReader);
            while (dataReader.Read())
                iCounts = dataReader.GetInt32(0);
            dataReader.Close();

            return iCounts;
        }
UserDB.UsersDB user = new UserDB.UsersDB();
                
                SqlDataReader reader = user.GetUserInfo(Int32.Parse(Page.User.Identity.Name));
                while (reader.Read())
                {
                    lblUserName.Text = reader.GetString(1);
                    lblFirstName.Text = reader.GetString(2);
                    lblLastName.Text = reader.GetString(3);
                    lblZodiacSign.Text = reader.GetString(6);
                    lblAge.Text = reader.GetInt32(7).ToString();
                    lblGender.Text = (reader.GetInt32(8) == 0) ? "Male" : "Female";
                    lblDateOfBirth.Text = reader.GetDateTime(9).ToString("d");
                    lblLastOnline.Text = reader.GetDateTime(15).ToString();
                    lblLocation.Text =  reader.GetString(22).ToString() + ", " + GetProvincesorStatesName(reader.GetString(20).ToString()) + ", " + GetCountryName(reader.GetString(19));
                    lblLoginCounts.Text = user.GetUserLoginCounts(Int32.Parse(Page.User.Identity.Name)).ToString();
 
                }

Open in new window

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

vs1784Commented:
Do one of the below
1. Change
    public static int GetUserLoginCounts(int userID)
                TO
    public int GetUserLoginCounts(int userID)

2.Change
    lblLoginCounts.Text = user.GetUserLoginCounts(Int32.Parse(Page.User.Identity.Name)).ToString();
                     TO
    lblLoginCounts.Text = UsersDB.GetUserLoginCounts(Int32.Parse(Page.User.Identity.Name)).ToString();

Hope it helps

Thanks

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
mathieu_cuprykAuthor Commented:
Conversion failed when converting the nvarchar value 'macupryk' to data type int.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting the nvarchar value 'macupryk' to data type int.

Source Error:


Line 208:            // run the stored procedure
Line 209:            data.RunProc("prcUserGetLoginCounts", prams, out dataReader);
Line 210:            while (dataReader.Read())
Line 211:                iCounts = dataReader.GetInt32(14);
Line 212:            dataReader.Close();
 
0
vs1784Commented:
It is altogether different error and not related to above. Please check that column is returning a text value and you are trying to convert it into integer.
0
mathieu_cuprykAuthor Commented:
I need to pass the userid not the username?
    lblLoginCounts.Text = UsersDB.GetUserLoginCounts(Int32.Parse(Page.User.Identity.Name)).ToString();
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
C#

From novice to tech pro — start learning today.