공유 데이터베이스 변수 (asp.net)의 오른쪽 방법 :나는 다음과 같은 코드를 사용하여 데이터베이스 변수를 공유 한
Namespace DataAccessVariables
Public Class Vars
Public Shared s As String
Public Shared con As String = WebConfigurationManager.ConnectionStrings("Dev").ToString()
Public Shared c As New SqlConnection(con)
Public Shared x As New SqlCommand(s, c)
End Class
End Namespace
나는 다음과 같이 내 프로젝트에이를 가져옵니다
Imports DataAccessVariables.Vars
을 FXCop으로 사이트를 확인하면 다음 메시지가 나타납니다.
Error, Certainty 90, for StaticHolderTypesShouldNotHaveConstructors
{
Target : DBVars (IntrospectionTargetType)
Resolution : "Remove the public constructors from 'Vars'."
Help : http://msdn2.microsoft.com/library/ms182169(VS.90).aspx (String)
Category : Microsoft.Design (String)
CheckId : CA1053 (String)
RuleFile : Design Rules (String)
Info : "Instances of types that define only static members
do not need to be created. Many compilers will automatically
add a public default constructor if no constructor
is specified. To prevent this, adding an empty private
constructor may be required."
Created : 2010/04/20 01:25:16 PM (DateTime)
LastSeen : 2010/04/21 07:17:46 AM (DateTime)
Status : Active (MessageStatus)
Fix Category : Breaking (FixCategories)
}
선언에서 '공용 공유'를 제거하면 ns이면 변수는 내 페이지에서 선택되지 않습니다. 누구든지 나와 공유하는 올바른 방법을 보여줄 수 있습니까?
감사합니다. Phil.