asp在SQL SER2k中新建帐号和给帐号权限的实现
' 以下为在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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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).

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 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.

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? 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

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 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.

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.
