Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to access MSSQL server?

152 views
Skip to first unread message

Adam Hair

unread,
Feb 26, 2003, 3:26:16 PM2/26/03
to
Hi,

I have the need to connect to a MSSQL database on another machine using
delphi. I have never done this before, and am having great difficulty
getting it to work.

I've tried the following (below) with no success. After asking a similar
question on the database-desktop newsgroup, Bill Todd informed me the best
way to access MSSQL is via the ADO components.

I am unfamiliar with these. Can someone please help me please. I can't find
anywhere to specify the machine network name or the database name. I'm
guessing these work a lot different to dbexpress and the BDE.

In the past, I have tried the following:

I have tried using the BDE to get a connection. Whenever I try to make a
connection I get the error message "Cannot load an IDAPI service library.
File: SQLMSS32.DLL"

I have not been able to find reference to this file anywhere.

I have also tried using dbexpress to access the data. To do this I:

Added a TSQLConnection component and double-clicked to bring up the editor.
Chose MSSQLConnection from the list and entered the hostname (SERVER),
Database, username (SA) and password (Blank). I also changed OS
Authentication to TRUE.

When I try to connect to the database, I get the error "SQL ERROR: Error
Maping Failed."
If I type in a password, I don't get this error, instead I get:

"SQL State: 42000, SQL Error Code: 18456 Login failed for user
'SERVER\Guest'"

I don't care how I connect to the database at the moment, whether BDE or
dbexpress, but I need a connection! Can anyone help please!

Both machines are on WinXP, and I'm using Delphi 7 Enterprise to try and
connect.

Thank & Regards

Adam Hair

Del Murrray

unread,
Feb 26, 2003, 3:59:08 PM2/26/03
to
Dont use BDE .. it wont work under ISAPI except just long enough to sucker
you. Use ADO as follows,

1. Drop ADO connection component on Datamodule. and give it a name like
cnMyConnection.

2. Set properties of "connectionstring" using the elipsis to build a
connection string (follow the bouncing ball). If you are not in the network
that contains the SQL Server you are trying to connect to then you will have
to create an Alias to the server using the Client Network Utilities of SQL
Server.

3. Test the connection while doing Step 2 above .. if it succeeds you have
half the battle licked.

4. Drop a TADODataset on the datamodule.

5. Set the "connection" property (not the connectionstring property) to
"cnMyConnection" or what ever you called it in step 1 above.

5. Set the "commandtype" to cmdText.

6. Set the "commandtext" to "select a,b,c from sometable " (use
appropriate stuff here. if you dont know sql, then you need to learn it ..
I'll assume you do for the time being.)

7. If the cnMyConnection is set to true and the new tADODataset "active"
property will set to true, you have connected to Sql Server and read some
data from the table designated in your sql command.

Make sure you have the right MDAC, but if XP it should be OK although I
claim no expertise with XP except to say I wouldn't develope under it unless
I wanted to be old and gray before my time, switch to W2K pro, it is easier
to debug under....

Hope this Helps

Adam Hair

unread,
Feb 26, 2003, 7:55:19 PM2/26/03
to
Hi Del,

Fantastic! Got it all working just wonderful.

Thanks & Regards

Adam Hair

"Del Murrray" <del.m...@credithawk.net> wrote in message
news:3e5d...@newsgroups.borland.com...

0 new messages