CREATE DATABASE not working from within .net 2010

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samvb
    New Member
    • Oct 2006
    • 228

    CREATE DATABASE not working from within .net 2010

    I generated SQL Server 2008 Database scripts. There are total 80 objects. The script executes successfully from sql server query. But not from .NET. That is I want to create the objects (tables and stored procedures) from there.

    If the database don't exist already in sql server, it fails. I have included the line

    Code:
    IF NOT EXIST (DATABASE)...
    
    CREATE DATABASE DBNAME
    But it simply don't work and the process fails while the code perfectly works directly in SQL Server.

    Any work around this? Can I run CREATE DATABASE somehow?
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    You can, but you need to make sure that the credentials you use to access your SQL Server via Visual Studio also have rights to create a database.

    Comment

    Working...