Acme.PROJECTNAME.Install.SqlServers.HasCreatePermissions C# (CSharp) Method

HasCreatePermissions() static private method

static private HasCreatePermissions ( string connectString ) : bool
connectString string
return bool
		internal static bool HasCreatePermissions(string connectString)
		{
			bool returnVal = false;
			System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
			SqlDataReader existsReader = null;
			try
			{
				conn.ConnectionString = connectString;
				conn.Open();
				SqlCommand cmdUserExist = new SqlCommand();
				cmdUserExist.CommandText = "use master select case when Permissions()&1=1 then 1 else 0 end as hasAccess";
				cmdUserExist.CommandType = System.Data.CommandType.Text;
				cmdUserExist.Connection = conn;
				existsReader = cmdUserExist.ExecuteReader();
				if(existsReader.Read())
				{
					try
					{
						if(int.Parse(existsReader["hasAccess"].ToString()) == 1)
						{
							returnVal = true;
						}
					}
					catch(Exception ex)
					{
						System.Diagnostics.Debug.WriteLine(ex.ToString());
					}
				}
			}
			catch(Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
			}
			finally
			{
				if(existsReader != null)
					existsReader.Close();
				if(conn != null)
					conn.Close();
			}
			return returnVal;
		}
		#endregion