Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Peter Laman, using the .NET provider, wanted to create a database if it did not exist, but CREATE DATABASE failed after connecting to sysmaster and DISCONNECT ALL gave a syntax error. Obnoxio The Clown suggested CLOSE DATABASE. Sheshnarayan Agrawal advised opening a second connection whose string omits the Database attribute and running CREATE DATABASE there. Peter confirmed that solved it.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Peter Laman — — source: Usenet: comp.databases.informix
Hello,
Using the .NET provider for Informix, I need to conditionally create a
database. So far, I connect to the 'sysmaster' database, to perform a
'SELECT name FROM sysdatabases WHERE name='databasename' query, which
tells me if the desired database already exists. But then, if the
database doesn't exist, I want to create it. So I try a 'CREATE
DATABASE' command, which fails, because an explicit connection has
been made. Then I tried a 'DISCONNECT ALL' first, but now IDS says
it's a syntax error.
Can anybody tell me what's wrong here?
Peter Laman wrote:
> Hello,
>
> Using the .NET provider for Informix, I need to conditionally create a
> database. So far, I connect to the 'sysmaster' database, to perform a
> 'SELECT name FROM sysdatabases WHERE name='databasename' query, which
> tells me if the desired database already exists. But then, if the
> database doesn't exist, I want to create it. So I try a 'CREATE
> DATABASE' command, which fails, because an explicit connection has
> been made.
Sounds a bit odd to me.
> Then I tried a 'DISCONNECT ALL' first, but now IDS says
> it's a syntax error.
>
> Can anybody tell me what's wrong here?
CLOSE DATABASE?
--
Cheers,
Obnoxio The Clown
http://obotheclown.blogspot.com
For this you have to open another connection (object) with connection
string whereas you don't provide value of "database=" attribute. This will
connect to only server and not database. Hence later on in your command
object you can execute "create database ..." query.
For example, In you existing scenario you might be saying something like
this
conn = new IfxConnection("Server=ol_shesh_ids1150;User
ID=informix;password=xxx;Database=sysmaster;");
In your new connection string you have to say (without "database="
attribute)
conn_new = new IfxConnection("Server=ol_shesh_ids1150;User
ID=informix;password=xxx;");
and then create command object and run "create database .." query.
HTH..
-Shesh
Peter Laman <peter.laman@gmail.com>
Sent by: informix-list-bounces@iiug.org
24/11/2008 18:25
To
informix-list@iiug.org
cc
Subject
Conditionally create database with .NET
Hello,
Using the .NET provider for Informix, I need to conditionally create a
database. So far, I connect to the 'sysmaster' database, to perform a
'SELECT name FROM sysdatabases WHERE name='databasename' query, which
tells me if the desired database already exists. But then, if the
database doesn't exist, I want to create it. So I try a 'CREATE
DATABASE' command, which fails, because an explicit connection has
been made. Then I tried a 'DISCONNECT ALL' first, but now IDS says
it's a syntax error.
Can anybody tell me what's wrong here?
_______________________________________________
Informix-list mailing list
Informix-list@iiug.org
http://www.iiug.org/mailman/listinfo/informix-list
↪ replying to Sheshnarayan Agrawal
Peter Laman — — source: Usenet: comp.databases.informix
Thanks Sheshnarayan Agrawal, your solution works. Thanks all the
others for your replies.
Peter
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.