Solved

Creating Databse!

Posted on 2004-04-14
7
198 Views
Last Modified: 2010-05-02
Hi All,

How to determine whether the MS SQL Server user has the premission to create database programmatically?

With Regards,
A.Ilamparithi.
0
Comment
Question by:callilam
  • 5
7 Comments
 
LVL 8

Expert Comment

by:dds110
Comment Utility
Error trapping!

You could attempt the create database functionality.  If it errs out, then he/she doesn't have the permission.  Otherwise, he/she does.  You'll need to determine the exact error number from SQL Server if you want to provide specific error handling.

Example:

Public Function CreateANewDB()
On Error GoTo err_create:
'code to create the new db

exit_create:
'clean up any used variables and close the function
Exit Function

err_create:
MsgBox Err.Description,,Err.Number
Resume exit_create:
End Sub


HTH
0
 
LVL 8

Expert Comment

by:dds110
Comment Utility
Hello?
0
 

Author Comment

by:callilam
Comment Utility
hi,

I dont want to create a database. But, just want to know whether the user has the previledge to create the database.

Also, It is not possible to create database from VB.

With Thanks,
A.Ilamparithi.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 8

Expert Comment

by:dds110
Comment Utility
OK, so try to create the database anyway.  If it's created, great, the user has access to create databases.  Then delete the database.

In addition, it is too possible to create a database from vb.  However, at this time i'm not sitting in front of a computer with vb installed so I can't be of much help.  But I'll look around and see what I can find for ya.
0
 
LVL 8

Accepted Solution

by:
dds110 earned 100 total points
Comment Utility
example of creating a database with sql server and vb
http://doc.ddart.net/mssql/sql2000/html/sqldmo/dmoref_ex01_0bs5.htm

checking the users permissions within sql server (article from http://www.winnetmag.com/SQLServer/Article/ArticleID/20176/20176.html)

***********************************************************************
How do I get the current user’s effective permissions?

If you want to check whether the current user has a certain statement, object, or column permission, you can use the PERMISSIONS() function. The PERMISSIONS() function gives you the effective permissions that result from NT groups, server roles, and the user’s database role membership as well as explicit permissions granted to that user.

You can invoke the PERMISSIONS() function with no arguments to check statement permissions, with an object ID to check object permissions, or with both an object ID and a column name to check column permissions. The function returns an integer with a bitmap that contains the effective permissions. SQL Server Books Online (BOL) provides a detailed explanation about how to use this function and which bits represent which permissions. Listing 5 contains a few examples that demonstrate how to use the PERMISSIONS() function.

***********************************************************************

You can use the ListDatabasePermissions Method of the user object (all done through sql-dmo) to enumerate the users permissions.  See this link for more info (it's in C, but I think you can manage).

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sqldmo/dmoref_ob_u_31v8.asp
0
 
LVL 8

Expert Comment

by:dds110
Comment Utility
hello?
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now