Well I spoke too soon. His method does work in code but not in the
ConnectionString property in the object inspector. This is becoming very
frustrating. Here's our code for setting up the connection on application
startup:
sDbConnStr := 'Provider=SQLOLEDB.1;Password=' + sDbPwd + ';'
+ 'Persist Security Info=True;User ID=' + sDbUsrName + ';'
+ 'Initial Catalog=CustDB;Data Source=' + sDbSrvName + ';Port=' +
sSqlPortNum;
cnnCon.ConnectionString := sDbConnStr;
try
cnnCon.Connected := true;
except
Windows.MessageBox(Application.Handle, 'Database connection failed.',
PChar(oInternalSysInfo.CoDBAName), MB_ICONINFORMATION or MB_OK);
Application.Terminate;
end;
The above works fine. If I set a break point and get the value of
"sDbConnStr" and then paste that into the ConnectionString property of the
object (without the quote marks of course) I get "Invalid connection string
attribute" as I'd expect.
If I change the code above to:
... + 'Initial Catalog=CustDB;Data Source=' + sDbSrvName + ',' +
sSqlPortNum;
it also works fine from code but NOT from the ConnectionString property in
the object inspector (I can paste it in there but when I try to set the
Connected property to true I get an error that it can't find the db.
Why would I get different behavior in code then I get in the object
inspector at design time?????
"Keith G Hicks" <***@comcast.net> wrote in message news:4377519f$***@newsgroups.borland.com...
Something even stranger. My brother (who's working with me on the same
project) couldn't get any of the stuff below to work so he tried "Data
Source = <server name>; Port = <Port #>" and it works for him. He found this
in a MySql webpage somewhere. We're both running MS SQL 2000 and not MySql.
What he's doing doesn't work at all on my machine. I'm clueless as to why it
would work on his. I'm wondering if this is some weird MDAC issue. I'm going
to check with him to see what version he has. I'm sure it's recent since
he's running Windows XP and has updated his SQL installation. I can't
beleive that would make a difference though.
"Keith G Hicks" <***@comcast.net> wrote in message news:43769a0c$***@newsgroups.borland.com...
Correct. It doesn't work. I can set up a connection string in code and it
works fine but if I enter it into the ConnectionString property of the
TAdoConnection object it doesn't work. Odd huh? Doesn't make much sense to
me. I have 2 connection objects on my data form. One is for run time and
the other is for design time. I set the connection string for the one used
at run time in code because it gets some info from the registry. It works
perfectly well including the port setting. The one I use during design time
is identical in every way except for the name of course. That's the one I'm
having trouble with. Like I said it doesn't really make any sense. My
connection string is simply like this:
Provider=SQLOLEDB.1;Password=<password>;Persist Security Info=True;User
ID=<user name>;Initial Catalog=<db name>;Data Source=<server name>,<port#>