| |
You are here: Experts > Computing/Technology > Delphi Programming > Delphi > Trouble making ODBC connection
Delphi - Trouble making ODBC connection
Expert: Randy Sill - 10/15/2009
Question QUESTION: Hello,
I am developing application using C++Builder. I use the TQuery object to execute queries to a local SQL Server 2000.
Recently I executed an SQL statement (which always succeeded before today) and I got error message like this:
Invalid parameter .
There is a dot in the error message. The SQL statement has no parameter or dot character.
Then I tried to make a new ODBC connection to the local SQL Server. On the first step, there is a server drop down list. And there is a dot listed in the drop down list. The computer name is not listed.
But strange, when I connect the computer to LAN, the computer name and (local) appears in the server drop down list.
What do you think is the problem?
Thank you,
Frans Indroyono
ANSWER: The single Dot often means "This PC". If I were to have a SQL server instance, I could use ".\InstName" as the server name just as easily as "MyPCName\InstName". If you are using the default SQL setup without instance then Server can be just "." and your connection will work fine. I often do that in a multi developer environment so that we're all pointing to our local system for database. Invalid parameter can mean a lot of things, so not sure what the cause of that error is. Have you tried the same command in Enterprise Manager query window?
---------- FOLLOW-UP ----------
QUESTION: Hello,
Somehow, the '.' problem solved after I removed a connection name from BDE. I think I have made two connections in ODBC dan BDE with the same name. So, I think that was the cause of the problem.
This morning, I got the same problem. This time there is no connection name duplication. I think I have to clear up the situation:
I am using one ODBC connection to SQL Server.
I have two modules using TQuery to connect a database using that ODBC connection.
One module goes very well.
The other module crash with error message: 'Invalid parameter .' there is a '.'
The query on the second module is fine. I tried it on Enterprise Manager or Query analyzer.
The thing that confuses me is: one connection, two TQueries. One TQuery succeeded, the other TQuery failed. Why?
I am using a querying module so the implementation (initialisation, executing query, getting query result, etc) on both TQuery are the same.
Any idea?
Thanks,
Frans
Answer I've avoided the BDE since there is an additional installation, configuration, and performance reduction. I use SDAC (SQL Data Access Components) and connect hundreds of queries to a single DB Connection with no trouble at all. I'm not sure what would be the issue with this Query.
Add to this Answer Ask a Question
|
|