internal static void CheckSchemaVersion(ProviderBase provider, SqlConnection connection, string[] features, string version, ref int schemaVersionCheck)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (features == null)
            {
                throw new ArgumentNullException("features");
            }

            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            if (schemaVersionCheck == -1)
            {
                throw new ProviderException(SR.GetString(SR.Provider_Schema_Version_Not_Match, provider.ToString(), version));
            }
            else if (schemaVersionCheck == 0)
            {
                lock (provider) {
                    if (schemaVersionCheck == -1)
                    {
                        throw new ProviderException(SR.GetString(SR.Provider_Schema_Version_Not_Match, provider.ToString(), version));
                    }
                    else if (schemaVersionCheck == 0)
                    {
                        int          iStatus = 0;
                        SqlCommand   cmd     = null;
                        SqlParameter p       = null;

                        foreach (string feature in features)
                        {
                            cmd = new SqlCommand("dbo.aspnet_CheckSchemaVersion", connection);

                            cmd.CommandType = CommandType.StoredProcedure;

                            p = new SqlParameter("@Feature", feature);
                            cmd.Parameters.Add(p);

                            p = new SqlParameter("@CompatibleSchemaVersion", version);
                            cmd.Parameters.Add(p);

                            p           = new SqlParameter("@ReturnValue", SqlDbType.Int);
                            p.Direction = ParameterDirection.ReturnValue;
                            cmd.Parameters.Add(p);

                            cmd.ExecuteNonQuery();

                            iStatus = ((p.Value != null) ? ((int)p.Value) : -1);
                            if (iStatus != 0)
                            {
                                schemaVersionCheck = -1;

                                throw new ProviderException(SR.GetString(SR.Provider_Schema_Version_Not_Match, provider.ToString(), version));
                            }
                        }

                        schemaVersionCheck = 1;
                    }
                }
            }
        }
示例#2
0
        internal static void CheckSchemaVersion(ProviderBase provider, SqlConnection connection, string[] features, string version, ref int schemaVersionCheck)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (features == null)
            {
                throw new ArgumentNullException("feature");
            }

            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            if (schemaVersionCheck == -1)
            {
                throw new Exception("The '" + provider.ToString() + "' requires a database schema compatible with schema version '" + version + "'.  However, the current database schema is not compatible with this version.  You may need to either install a compatible schema with aspnet_reqsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.");
            }
            else if (schemaVersionCheck == 0)
            {
                lock (provider)
                {
                    if (schemaVersionCheck == -1)
                    {
                        throw new Exception("The '" + provider.ToString() + "' requires a database schema compatible with schema version '" + version + "'.  However, the current database schema is not compatible with this version.  You may need to either install a compatible schema with aspnet_reqsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.");
                    }
                    else if (schemaVersionCheck == 0)
                    {
                        int          iStatus = 0;
                        SqlCommand   cmd     = null;
                        SqlParameter p       = null;

                        foreach (string feature in features)
                        {
                            cmd = new SqlCommand("dbo.aspnet_CheckSchemaVersion", connection);

                            cmd.CommandType = CommandType.StoredProcedure;

                            p = new SqlParameter("@Feature", feature);
                            cmd.Parameters.Add(p);

                            p = new SqlParameter("@CompatibleSchemaVersion", version);
                            cmd.Parameters.Add(p);

                            p           = new SqlParameter("@ReturnValue", SqlDbType.Int);
                            p.Direction = ParameterDirection.ReturnValue;
                            cmd.Parameters.Add(p);

                            cmd.ExecuteNonQuery();

                            iStatus = ((p.Value != null) ? ((int)p.Value) : -1);
                            if (iStatus != 0)
                            {
                                schemaVersionCheck = -1;

                                throw new Exception("The '" + provider.ToString() + "' requires a database schema compatible with schema version '" + version + "'.  However, the current database schema is not compatible with this version.  You may need to either install a compatible schema with aspnet_reqsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.");
                            }
                        }

                        schemaVersionCheck = 1;
                    }
                }
            }
        }
 internal static void CheckSchemaVersion(ProviderBase provider, SqlConnection connection, string[] features, string version, ref int schemaVersionCheck)
 {
     if (connection == null)
     {
         throw new ArgumentNullException("connection");
     }
     if (features == null)
     {
         throw new ArgumentNullException("features");
     }
     if (version == null)
     {
         throw new ArgumentNullException("version");
     }
     if (schemaVersionCheck == -1)
     {
         throw new ProviderException(System.Web.SR.GetString("Provider_Schema_Version_Not_Match", new object[] { provider.ToString(), version }));
     }
     if (schemaVersionCheck == 0)
     {
         lock (provider)
         {
             if (schemaVersionCheck == -1)
             {
                 throw new ProviderException(System.Web.SR.GetString("Provider_Schema_Version_Not_Match", new object[] { provider.ToString(), version }));
             }
             if (schemaVersionCheck == 0)
             {
                 SqlCommand   command   = null;
                 SqlParameter parameter = null;
                 foreach (string str in features)
                 {
                     command = new SqlCommand("dbo.aspnet_CheckSchemaVersion", connection)
                     {
                         CommandType = CommandType.StoredProcedure
                     };
                     parameter = new SqlParameter("@Feature", str);
                     command.Parameters.Add(parameter);
                     parameter = new SqlParameter("@CompatibleSchemaVersion", version);
                     command.Parameters.Add(parameter);
                     parameter = new SqlParameter("@ReturnValue", SqlDbType.Int)
                     {
                         Direction = ParameterDirection.ReturnValue
                     };
                     command.Parameters.Add(parameter);
                     command.ExecuteNonQuery();
                     if (((parameter.Value != null) ? ((int)parameter.Value) : -1) != 0)
                     {
                         schemaVersionCheck = -1;
                         throw new ProviderException(System.Web.SR.GetString("Provider_Schema_Version_Not_Match", new object[] { provider.ToString(), version }));
                     }
                 }
                 schemaVersionCheck = 1;
             }
         }
     }
 }
 public static void CheckSchemaVersion(
     ProviderBase provider,
     SqlConnection connection,
     string[] features,
     string version,
     ref int schemaVersionCheck)
 {
     if (connection == null)
     {
         throw new ArgumentNullException(nameof(connection));
     }
     if (features == null)
     {
         throw new ArgumentNullException(nameof(features));
     }
     if (version == null)
     {
         throw new ArgumentNullException(nameof(version));
     }
     if (schemaVersionCheck == -1)
     {
         throw new ProviderException(SuperResource.GetString("Provider_Schema_Version_Not_Match", (object)provider.ToString(), (object)version));
     }
     if (schemaVersionCheck != 0)
     {
         return;
     }
     lock (provider)
     {
         if (schemaVersionCheck == -1)
         {
             throw new ProviderException(SuperResource.GetString("Provider_Schema_Version_Not_Match", (object)provider.ToString(), (object)version));
         }
         if (schemaVersionCheck != 0)
         {
             return;
         }
         foreach (string feature in features)
         {
             SqlCommand sqlCommand = new SqlCommand("dbo.aspnet_CheckSchemaVersion", connection);
             sqlCommand.CommandType = CommandType.StoredProcedure;
             SqlParameter sqlParameter1 = new SqlParameter("@Feature", (object)feature);
             sqlCommand.Parameters.Add(sqlParameter1);
             SqlParameter sqlParameter2 = new SqlParameter("@CompatibleSchemaVersion", (object)version);
             sqlCommand.Parameters.Add(sqlParameter2);
             SqlParameter sqlParameter3 = new SqlParameter("@ReturnValue", SqlDbType.Int);
             sqlParameter3.Direction = ParameterDirection.ReturnValue;
             sqlCommand.Parameters.Add(sqlParameter3);
             sqlCommand.ExecuteNonQuery();
             if ((sqlParameter3.Value != null ? (int)sqlParameter3.Value : -1) != 0)
             {
                 schemaVersionCheck = -1;
                 throw new ProviderException(SuperResource.GetString("Provider_Schema_Version_Not_Match", (object)provider.ToString(), (object)version));
             }
         }
         schemaVersionCheck = 1;
     }
 }
示例#5
0
        /// <summary>
        /// 检查版本
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="connection"></param>
        /// <param name="features"></param>
        /// <param name="version"></param>
        /// <param name="schemaVersionCheck"></param>
        internal static void CheckSchemaVersion(ProviderBase provider, SqlConnection connection, string[] features, string version, ref int schemaVersionCheck)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (features == null)
            {
                throw new ArgumentNullException("feature");
            }

            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            if (schemaVersionCheck == -1)
            {
                throw new Exception("The '" + provider.ToString() + "' requires a database schema compatible with schema version '" + version + "'.  However, the current database schema is not compatible with this version.  You may need to either install a compatible schema with aspnet_reqsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.");
            }
            else if (schemaVersionCheck == 0)
            {
                lock (provider)
                {
                    if (schemaVersionCheck == -1)
                    {
                        throw new Exception("The '" + provider.ToString() + "' requires a database schema compatible with schema version '" + version + "'.  However, the current database schema is not compatible with this version.  You may need to either install a compatible schema with aspnet_reqsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.");
                    }

                    /*
                     * 检测是否存在SchemaVersion
                     * 2005-11-17
                     * common	1	1
                     *  health monitoring	1	1
                     *  membership	1	1
                     *  personalization	1	1
                     *  profile	1	1
                     *  role manager	1	1
                     *
                     */
                    //else if (schemaVersionCheck == 0)
                    //{
                    //    int iStatus = 0;
                    //    SqlCommand cmd = null;
                    //    SqlParameter p = null;

                    //    foreach (string feature in features)
                    //    {
                    //        cmd = new SqlCommand("dbo.aspnet_CheckSchemaVersion", connection);

                    //        cmd.CommandType = CommandType.StoredProcedure;

                    //        p = new SqlParameter("@Feature", feature);
                    //        cmd.Parameters.Add(p);

                    //        p = new SqlParameter("@CompatibleSchemaVersion", version);
                    //        cmd.Parameters.Add(p);

                    //        p = new SqlParameter("@ReturnValue", SqlDbType.Int);
                    //        p.Direction = ParameterDirection.ReturnValue;
                    //        cmd.Parameters.Add(p);

                    //        cmd.ExecuteNonQuery();

                    //        //RETURN 0 存在 1 不存
                    //        iStatus = ((p.Value != null) ? ((int)p.Value) : -1);
                    //        if (iStatus != 0)
                    //        {
                    //            schemaVersionCheck = -1;

                    //            throw new Exception("The '" + provider.ToString() + "' requires a database schema compatible with schema version '" + version + "'.  However, the current database schema is not compatible with this version.  You may need to either install a compatible schema with aspnet_reqsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.");
                    //        }
                    //    }

                    //    schemaVersionCheck = 1;
                    //}
                }
            }
        }