November 1, 2004 at 1:25 am
Does anyone know how to set the connection string for a connection to SQL Server from a VB6 DataEnvironment Connection at run time? Updating the connections connection string at runtime is totally ignored. Opening and closing the connection is to no avail.
Keith
November 2, 2004 at 6:45 am
I'm not sure I get your problem. Are you trying to use the same connection object to connect to another server or another DB and that isn't working or you can't connect at all?
Have you tried? :
MyCn.Close
set MyCn = Nothing
set MyCn = new ADODB.Connection
MyCn.Open "New string..."
November 2, 2004 at 9:09 am
Check out this site for various forms of connection strings...
November 2, 2004 at 9:20 am
I was under the impression that DataEnvironment properties were set at design time. I wouldn't be surprised to find that you can dynamically reconfigure the DataEnvironment at runtime, but my question would be why bother? (I haven't used DataEnvironments very much, although I have been using SQL Server & VB since VB 3 & SQL 6.5.)
Why don't you just use ADO connection, command, and recordset objects? Sometimes I use the ADO Data Control to build connection strings, or the DataEnvironment to build queries (great for heirarchical recordsets), but I copy the actual connection string or SQL statements and run them in code. I like being in control of when things are opened & closed, or options such as cursor type and synchronous vs asynchronous execution.
November 2, 2004 at 12:37 pm
Have you tried something like the following?
gdbData is the Designer
conATOMS is the connection
"Production" is the name of the server i want to connect to in runtime. I use "Development" when I'm testing.
gdbData.conATOMS.Open "Production"
If the phone doesn't ring...It's me.
November 2, 2004 at 11:38 pm
As Scott Coleman says you can set the DataEnvironment properties at designtime which works fine but trying to change things at runtime doesn't seem to work. This means you have to recompile the app if you need to move or rename the database etc
Unfortunately I have inherited the app and don't want to make big changes to it now as it is my intention to replace it in the hopefully not to distant future.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply