Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Error - An object reference is required for the non-static field, method, or property 'GISA.Default.GetConnectionString()'

$
0
0

Hi,

Could somebody please advice on the error I am getting while building the solution. The error comes up on the following code (bold and italic):

public static bool CheckUser()
        {
            SqlConnection myQuery;myQuery = new SqlConnection GetConnectionString();            myQuery.Open();
            string UserName = WindowsIdentity.GetCurrent().Name;             
            SqlCommand getUserID = new SqlCommand("Select level FROM [Admin_user] WHERE [AD_Name] = @UserName", myQuery);
            getUserID.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar)).Value = UserName;
            SqlDataReader r = getUserID.ExecuteReader();

            if (r.HasRows == false)
            {

                r.Close();             
return false; } r.Read(); r.Close();
return true; }

Thanks.

 


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>