Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 creating a database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-22 : 08:17:33
Graham writes "

In answer http://www.4guysfromrolla.com/webtech/sqlguru/q080400-2.shtml
you say that creating a database is as simple as executing

CREATE DATABASE name

and that it's simple to port that SQL to ASP.

However, when I try to execute this SQL in ASP like so:


Set cmdFiltered = Server.CreateObject("ADODB.Command")
cmdFiltered.CommandText = "CREATE DATABASE name"
cmdFiltered.CommandType = adCmdText
cmdFiltered.Execute


I get an error informing me that
"Operation is not allowed on an object referencing a closed or invalid connection."

But I cannot give the command object an open connection to work with because that requires a filename and the file hasn't been created yet.

This seems to be a catch-22 that makes your SQL answer useless in ASP."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-12-22 : 08:20:27
OK, you need to relax a bit.

A. It's not "our" SQL answer, it's some code posted on 4GuysFromRolla. This site is SQL Team.
B. There's an omission:

cmdFiltered.ActiveConnection = objConn 'this is your ADO connection object

If you look on 4Guys you'll find more examples of the ADO Command and Connection objects. Make sure your Connection object does not connect to a specific database or Initial Catalog setting.
Go to Top of Page
   

- Advertisement -