Before I pull out my hair, ADO.NET and VB.NET :D

  • 15 years ago

    I've been looking for an answer to this for quite awhile!


    Questions:
    1. Is there a way in ADO.NET w/ VB.NET, that I may query the SQL Server on what databases it has (just need the names)?
    2. Is there a way in ADO.NET w/ VB.NET, that I can create a database in an SQL server?


    Comments:
    1. Stored Procedures are really no help here. , I had already looked through them
    2. I know how to create tables inside a database, but how to create an actual database on the server? (assuming that you have the right permissions)


    Any help will be greatly appreciated and my hair will be saved!!!


    Thanks,
    Tony

  • 15 years ago

    I'm not sure if there are any native ado.net commands, but to retrieve a list of databases, you can call the sp_databases stored procedure on SQL Server. To create a database, you can use the CREATE DATABASE command:


    Code:
    USE master
    GO
    CREATE DATABASE Sales
    ON
    ( NAME = Salesdat,
      FILENAME = 'c:\program files\microsoft sql server\mssql\data\saledat.mdf',
      SIZE = 10,
      MAXSIZE = 50,
      FILEGROWTH = 5 )
    LOG ON
    ( NAME = 'Sales
    log',
      FILENAME = 'c:\program files\microsoft sql server\mssql\data\salelog.ldf',
      SIZE = 5MB,
      MAXSIZE = 25MB,
      FILEGROWTH = 5MB )
    GO




    plz note that this is very specific to SQL Server!!


    (i found all of this in the SQL Server manual)

  • 15 years ago

    Interesting... Thanks James. , I think I have tried the sp_databases sp b4 and had unsuccessful outcomes, but I'll try again

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan