Home Database Mysql Tutorial asp在SQL SER2k中新建帐号和给帐号权限的实现

asp在SQL SER2k中新建帐号和给帐号权限的实现

Jun 07, 2016 pm 03:07 PM
a asp sql accomplish New Permissions

' 以下为在asp中增加一个sql server2000用户函数,并为建立一个数据库,给他dbo的 权限 ' ****************注意:sql server的验证方式不要选仅为windows方式, ' **************** 允许远程sql server连接 ' ****************该函数已通过测试*************

  ' 以下为在asp中增加一个sql server2000用户函数,并为建立一个数据库,给他dbo的权限

  ' ****************注意:sql server的验证方式不要选仅为windows方式,

  ' ****************     允许远程sql server连接

  ' ****************该函数已通过测试****************************

  ' 有什么问题欢迎和我交流,以后会推出对sql server的一些管理操作程序

  ' 参数:StrLoginName:新增登录名,StrPwd:登录名的密码,StrDBName:新建数据库名

  ' 函数内局部变量说明:StrServer:服务器所在机器名(本机为local),StrUid:sql管理员,

  ' StrSaPwd:sql管理员密码。以上三个变量应根据你的情况设置

  ' 该函数主要调用系统存储过程来实现

  ' 注意:本函数没有容错处理,如出现错误,可以确定是你的sql server设置有问题,或已存在该login帐号或该数据库

  ' call AddUserToMSSQL("testlogin","iamhere","db_test")

  Sub AddUserToMSSQL(StrLoginName,StrPwd,StrDBName)

  '定义服务器变量和系统管理员登录信息,根据具体情况修改

  Dim StrServer,StrUid,StrSaPwd

  StrServer="(local)"

  StrUid="sa"

  StrSaPwd=""

  Dim Conn '数据库连接

  Dim StrDSN '数据库连接字符串

  Dim StrCmd '命令字符串

  StrDSN="driver={SQL server};server="&StrServer&";uid="&StrUid&";pwd="&StrSaPwd&";database=master"

  '建立和数据库master的连接

  set Conn = Server.CreateObject("ADODB.Connection")

  Conn.Open StrDSN

  '新建一数据库

  StrCmd="CREATE DATABASE "&StrDBName

  Conn.execute(StrCmd)

  '新建一登录帐号

  StrCmd="sp_addlogin '"&StrLoginName&"','"&StrPwd&"','"&StrDBName&"'"

  Conn.execute(StrCmd)

  Conn.Close

  '建立与新建数据库的连接,并赋给新登录帐号访问新建数据库的权利

  StrDSN="driver={SQL server}; server="&StrServer&";uid="&StrUid&";pwd="&StSarPwd&";database="&StrDBName

  StrCmd="sp_grantdbaccess '"&StrLoginName&"'"

  Conn.Open StrDSN

  Conn.execute(StrCmd)

  '使新登录帐号成为新建数据库的拥有者

  StrCmd="sp_addrolemember 'db_owner','"&StrLoginName&"'"

  Conn.execute(StrCmd)257108.com

  '关闭释放连接

  Conn.Close

  Set Conn=Nothing

  Response.Write "用户 "&StrLoginName&" 成功建立!,并且已为他建立了一个数据库 "&StrDBName&"!"

  End Sub

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Enable root permissions with one click (quickly obtain root permissions) Enable root permissions with one click (quickly obtain root permissions) Jun 02, 2024 pm 05:32 PM

It allows users to perform more in-depth operations and customization of the system. Root permission is an administrator permission in the Android system. Obtaining root privileges usually requires a series of tedious steps, which may not be very friendly to ordinary users, however. By enabling root permissions with one click, this article will introduce a simple and effective method to help users easily obtain system permissions. Understand the importance and risks of root permissions and have greater freedom. Root permissions allow users to fully control the mobile phone system. Strengthen security controls, customize themes, and users can delete pre-installed applications. For example, accidentally deleting system files causing system crashes, excessive use of root privileges, and inadvertent installation of malware are also risky, however. Before using root privileges

Usage of division operation in Oracle SQL Usage of division operation in Oracle SQL Mar 10, 2024 pm 03:06 PM

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

How to implement dual WeChat login on Huawei mobile phones? How to implement dual WeChat login on Huawei mobile phones? Mar 24, 2024 am 11:27 AM

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

PHP Programming Guide: Methods to Implement Fibonacci Sequence PHP Programming Guide: Methods to Implement Fibonacci Sequence Mar 20, 2024 pm 04:54 PM

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones How to implement the WeChat clone function on Huawei mobile phones Mar 24, 2024 pm 06:03 PM

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

How to solve the 5120 error in SQL How to solve the 5120 error in SQL Mar 06, 2024 pm 04:33 PM

Solution: 1. Check whether the logged-in user has sufficient permissions to access or operate the database, and ensure that the user has the correct permissions; 2. Check whether the account of the SQL Server service has permission to access the specified file or folder, and ensure that the account Have sufficient permissions to read and write the file or folder; 3. Check whether the specified database file has been opened or locked by other processes, try to close or release the file, and rerun the query; 4. Try as administrator Run Management Studio as etc.

See all articles