Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Creating an empty SQL database.

Creating an empty SQL database.

Scheduled Pinned Locked Moved Database
databasecsharpasp-netquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Segal
    wrote on last edited by
    #1

    I started using ADO.NET to access data from SQL database in my ASP.NET applications, however, those commands I used so far is to talk to an existed database. If I want to create a new database, is there any easy way to do it in ADO or sth. else? Thanks a lot!

    J 1 Reply Last reply
    0
    • S Segal

      I started using ADO.NET to access data from SQL database in my ASP.NET applications, however, those commands I used so far is to talk to an existed database. If I want to create a new database, is there any easy way to do it in ADO or sth. else? Thanks a lot!

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      Assuming you are connected to the server as a user that has the rights to create a database (and next some tables) CREATE DATABASE <database name>; look up in Books Online the syntax for CREATE DATABASE to see all the different settings you can specify. While you're looking that up, look up CREATE TABLE too, because you'll need some tables added in order to do much with that database :)

      James Sig code stolen from David Wulff

      S 1 Reply Last reply
      0
      • J James T Johnson

        Assuming you are connected to the server as a user that has the rights to create a database (and next some tables) CREATE DATABASE <database name>; look up in Books Online the syntax for CREATE DATABASE to see all the different settings you can specify. While you're looking that up, look up CREATE TABLE too, because you'll need some tables added in order to do much with that database :)

        James Sig code stolen from David Wulff

        S Offline
        S Offline
        Segal
        wrote on last edited by
        #3

        This is a sql command, and I normally use ADO's object SQLcommand and its method "command.ExecuteNonQuery()" to execute the required sql command in my C# program or ASP.NET c# server code. However, that SQLcommand object requires connection first, which needs to have a existed DB available. So in this case, sqlcommand may not be a good choice to run that creation command. Any ideas any other object I can use in my C# program? Thanks a lot!

        J 1 Reply Last reply
        0
        • S Segal

          This is a sql command, and I normally use ADO's object SQLcommand and its method "command.ExecuteNonQuery()" to execute the required sql command in my C# program or ASP.NET c# server code. However, that SQLcommand object requires connection first, which needs to have a existed DB available. So in this case, sqlcommand may not be a good choice to run that creation command. Any ideas any other object I can use in my C# program? Thanks a lot!

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          You can connect to SQL server without using a specific database. If you specify CATALOG in your connection string, remove it; and you should be ok. The account you use to connect to SQL Server (either Windows authentication or username/password authentication) needs to have permissions to create databases.

          James Sig code stolen from David Wulff

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups