Re: Newbie Question About DB Connection via Internet

2003-08-14 07:13:56 PM
Sheila Nelson writes:
I have several applications developed in Delphi 4 Client/Server that run
against a Microsoft SQL Server on our local area network. I need to
modify these applications so they connect to a SQL server via the
internet -- preferably without the client using a browser. I've
purchased the Enterprise version of Delphi 6. Is it possible to do what
I'm trying to do and, if so, can someone tell me which of the
internet-based components in Delphi 6 I'd use? If I absolutely have
to use a browser, is there a method that would not require rewriting all
of my code in HTML? I am not asking for a lot of detail -- just a little
push in the right direction.
You could try the "remote" ADO provider:
ConnectionString : string;
ConnectionString := 'Provider=MS Remote;' +
'Remote Provider=sqloledb;' +
'Data Source=theserver;' +
'Initial Catalog=thedb;' +
It's basically a normal ADO connection string, but the provider is
now "MS Remote" and you delegate the *actual* provider to the "Remote
Provider" property.
If the remote machine is set up as a web server, you could also use
Delphi's Internet components to execute some basic ASP scrips on the
server and get the results right into your application.
So a VERY basic ASP file could be:
Dim oCnn, oRS, strSQL
Set oCnn = Server.CreateObject("ADODB.Connection")
oCnn.Open "Provider=sqloledb;blah;blah"
strSQL = Request.QueryString(SQL)
Set oRS = oCnn.Execute(SQL)
while not oRS.EOF
' e.g. write the first two fields delimited with a pipe
Response.Write oRS(0).Value & "|" & oRS(1).Value & vbCrLf
If you used a Delphi HTTP component to connect to this URL: * FROM COMPANIES
your application would get the data as plain text for you to parse.
Remove the -not from email