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!

    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?

    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!!!


  • 15 years ago

    I'm not sure if there are any native 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:

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

    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).


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.

“Debuggers don't remove bugs. They only show them in slow motion.”