GetServerTypes Method
Collapse the table of content
Expand the table of content

DatabaseProvider.GetServerTypes Method

IIS 7.0

Returns the list of supported server types for a database provider.

Namespace:  Microsoft.Web.Management.DatabaseManager
Assembly:  Microsoft.Web.Management.DatabaseManager (in Microsoft.Web.Management.DatabaseManager.dll)

public abstract ICollection<TypeInfo> GetServerTypes(
	string connectionString
)

Parameters

connectionString
Type: System.String
The connection string for the database connection.

Return Value

Type: System.Collections.Generic.ICollection<TypeInfo>
A read-only ICollection object that contains a collection of TypeInfo objects.

Your provider must implement the GetServerTypes method in order to return the database types for your provider.

NoteNote:

The types for a provider vary greatly between database servers; you must consult the documentation for your database server in order to construct the list of server types for your provider.

The following code sample illustrates an example GetServerTypes method that returns a list of database types for an OLEDB provider.



        public override ICollection<TypeInfo> GetServerTypes(
            string connectionString )
        {
            List<TypeInfo> types = new List<TypeInfo>();
            TypeInfo info;

            // Add a Binary type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = true;
            info.AllowNulls = true;
            info.IsBinary = true;
            info.IsVariableLength = false;
            info.Name = "Binary";
            types.Add(info);

            // Add a Bit type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "Bit";
            types.Add(info);

            // Add a Byte type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "Byte";
            types.Add(info);

            // Add a Currency type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.HasPrecision = true;
            info.MaximumPrecision = 28;
            info.DefaultPrecision = 18;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "Currency";
            types.Add(info);

            // Add a DateTime type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "DateTime";
            types.Add(info);

            // Add a Decimal type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.HasPrecision = true;
            info.MaximumPrecision = 28;
            info.DefaultPrecision = 18;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "Decimal";
            types.Add(info);

            // Add a Float type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "Float";
            types.Add(info);

            // Add an Integer type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "Integer";
            types.Add(info);

            // Add a Real type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "Real";
            types.Add(info);

            // Add a SmallInt type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = false;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "SmallInt";
            types.Add(info);

            // Add a Text type.
            info = new TypeInfo();
            info.AllowIdentity = false;
            info.AllowLength = true;
            info.AllowNulls = true;
            info.IsBinary = false;
            info.IsVariableLength = true;
            info.Name = "Text";
            types.Add(info);

            // Add a UNIQUEIDENTIFIER type.
            info = new TypeInfo();
            info.AllowIdentity = true;
            info.AllowLength = false;
            info.AllowNulls = false;
            info.IsBinary = false;
            info.IsVariableLength = false;
            info.Name = "UniqueIdentifier";
            types.Add(info);

            return types;
        }



Show:
© 2016 Microsoft