我建立了一个小局域网,服务器装SQL Server 2000,客户端用VB 6.0开发管理软件,以往增加操作员时,都由系统管理员在服务器上,用“企业管理器"搞定,现在想由某个操作员在客户端,通过管理软件的功能来增加用户,这样的程序该怎么编?谢谢。
解决方案 »
- 用vb6.0编写的软件很容易被反编译吗?
- 网络考试系统怎么做?
- active x 控件的注册问题
- 哪位仁兄告诉我下,在 label显示文本,空行的字符是什么啊!!!???谢谢了!!
- 为什么我datareport不能二次更新(新学报表)
- 请问vb6chs.dll;vb6stdkit.dll是不是在98.2000.xp下的vb开发的程序都需要并且注册么?
- java当中的long数组 如何在vb中定义
- 如何在vb代码中建立odbc数据源
- datagrid控件如何在前面显示行号
- 怎样能使tooltiptext提示分两行或更多行显示
- 如何将VB中的datagrid数据导出excel,word中去???
- 如何删除A表中B表没有的内容??
为 Microsoft® SQL Server™ 登录或 Microsoft Windows NT® 用户或组在当前数据库中添加一个安全帐户,并使其能够被授予在数据库中执行活动的权限。语法
sp_grantdbaccess [@loginame =] 'login'
[,[@name_in_db =] 'name_in_db' [OUTPUT]]参数
[@loginame =] 'login'当前数据库中新安全帐户的登录名称。Windows NT 组和用户必须用 Windows NT 域名限定,格式为"域\用户",例如 LONDON\Joeb。登录不能使用数据库中已有的帐户作为别名。login 的数据类型为 sysname,没有默认值。[@name_in_db =] 'name_in_db' [OUTPUT]数据库中帐户的名称。name_in_db 是 sysname 类型的 OUTPUT 变量,默认值为 NULL。如果没有指定,则使用 login。如果将其指定为 NULL 值的 OUTPUT 变量,则设置 @name_in_db 为 login。当前数据库不必存在 name_in_db。返回代码值
0(成功)或 1(失败)注释
SQL Server 用户名可以包含 1 到 128 个字符,包括字母、符号和数字。但是,用户名不能: 含有反斜线符号 (\)。
为 NULL,或为空字符串 ('')。
在使用安全帐户访问数据库之前,必须授予它对当前数据库的访问权。使用 sp_grantdbaccess 仅可以管理当前数据库中的帐户。若要从数据库中删除帐户,请使用 sp_revokedbaccess。如果当前数据库中没有 guest 安全帐户,而且 login 为 guest,则可以添加 guest 的安全帐户。sa 登录不能添加到数据库中。 不能从用户定义的事务中执行 sp_grantdbaccess。权限
只有 sysadmin 固定服务器角色、db_accessadmin 和 db_owner 固定数据库角色的成员才能执行 sp_grantdbaccess。示例
下面的示例在当前数据库中为 Windows NT 用户 Corporate\GeorgeW 添加帐户,并取名为 Georgie。EXEC sp_grantdbaccess 'Corporate\GeorgeW', 'Georgie'
Adds a security account for a new user in the current database. This procedure is included for backward compatibility. Use sp_grantdbaccess.Syntax
sp_adduser [ @loginame = ] 'login'
[ , [ @name_in_db = ] 'user' ]
[ , [ @grpname = ] 'group' ] Arguments
[@loginame =] 'login'Is the name of the user's login. login is sysname, with no default. login must be an existing Microsoft® SQL Server™ login or Microsoft Windows NT® user.[@name_in_db =] 'user'Is the name for the new user. user is sysname, with a default of NULL. If user is not specified, the name of the user defaults to the login name. Specifying user gives the new user a name in the database different from the login ID on SQL Server.[@grpname =] 'group'Is the group or role that the new user automatically becomes a member of. group is sysname, with a default of NULL. group must be a valid group or role in the current database. Microsoft SQL Server version 7.0 uses roles instead of groups.Return Code Values
0 (success) or 1 (failure)Res
SQL Server usernames can contain from 1 to 128 characters, including letters, symbols, and numbers. However, usernames cannot: Contain a backslash character (\).
Be NULL, or an empty string ('').
After a user has been added, use the GRANT, DENY, and REVOKE statements to define the permissions controlling the activities performed by the user.Use sp_helplogin to display a list of valid login names.Use sp_helprole to display a list of the valid role names. When specifying a role, the user automatically gains the permissions that are defined for the role. If a role is not specified, the user gains the permissions granted to the default public role. To add a user to a role, a value for username must be supplied (username can be the same as login_id.)To access a database, a login must be granted access by using sp_adduser or sp_grantdbaccess, or the guest security account must exist in the database.sp_adduser cannot be executed inside a user-defined transaction.Permissions
Only the dbo and members of the sysadmin fixed server role can execute sp_adduser.Examples
A. Add a user
This example adds the user Victoria to the existing fort_mudge role in the current database, using the existing login Victoria.EXEC sp_adduser 'Victoria', 'Victoria', 'fort_mudge'B. Add a username with the same login ID
This example adds the default username Margaret to the current database for the login Margaret, which belongs to the default public role.EXEC sp_adduser 'Margaret'C. Add a user who uses a different username
This example adds the Haroldq login to the current database with a username of Harold, which belongs to the fort_mudge role.EXEC sp_adduser 'Haroldq', 'Harold', 'fort_mudge'在vb执行sql语句就行