🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #3035

Re: Problem connecting MSSQL

#3035
From: Giuliano
Date: Sun, 29 Dec 2002 21:27
46 lines
2219 bytes
On Sun, 29 Dec 2002 18:55:36 +0100, "Ing Giuseppe Monteleone"
<info@ing-monteleone.com> wrote:

>Hi guys,
>
>I have a strange problem with MSSQL 2000. With a TADOConnection I can
>connect only when i put the connection string in the Object Inspector. When
>i put the same string with istruction
>
>adoConnection->ConnectionString = conString;
>
>does not work.
>
>I need to assign it dinamically because I need to acess to two different
>database (an user choice)
>
>Thanks
>Giuseppe Monteleone
>

Which kind of "strange problem"?

Maybe you are trying to change the connection string in a wrong place. 
A good place to change the connection string could be in the Before Connect
event's body. For example:

void __fastcall TdmMain::adoConnectionBeforeConnect(TObject *Sender)
{
    adoConnection->ConnectionString = GetAConnectionString();
}

Also, make sure to invoke 'Disconnect' before changing the connection string
if you are already connected. For example, try with something like the
following code:

void __fastcall TdmMain::SetConnString( AnsiString Val )
{
    if ( Val != adoConnection->ConnectionString ) {
        Disconnect();
        adoConnection->ConnectionString = Val;
    }
}

Hope this helps.

Giuliano
Technical Details
Message-ID: <9opu0vgqlb2ddekhq3130igajbkjvv9djv@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3e0f38cf$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,9ee150b859acac1e
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-12-29 13:39:38 PST
From: Giuliano <gcardinali@remove.adhoc.net>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Problem connecting MSSQL
Date: Sun, 29 Dec 2002 22:27:15 +0100
Message-ID: <9opu0vgqlb2ddekhq3130igajbkjvv9djv@4ax.com>
References: <3e0f38cf$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.72.236.130
X-Trace: newsgroups.borland.com 1041197233 81.72.236.130 (29 Dec 2002 13:27:13 -0800)
Lines: 46
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail