How to connect to a MS Access database over LAN using Delphi? - delphi

I am writing an application that extracts data from a file and then saves the data in a MS Access database. I now want to write a client for this program where users can view the data with a nice GUI. How do I connect the client on another PC to the database on my PC using Delphi? For starters I would just like to display the MS Access Data in a DB Grid. I have never worked with networking before in Delphi.

There are lots of ways to do this. One simple way is just to set up an ODBC connection to the database (using ODBC administrator). It doesn't matter if this database is over the network - just map a drive or use a fully qualified name.
You then have a choice of components you can use to connect to the database. ADO is a good choice for Access. For starters try using a TADOQuery, TDataSource and data aware component such as a TDBGrid. There is plenty of documentation on how to uses these in the delphi help.

Related

How to connect to a SQL server table from Crystal Reports 8.5 in Delphi 7

Can anyone show us some sample code to login and connect from D7 via UCRPE32.pas two tables (via Windows or SQL Authentication... both needed at different times.)
Details: We are migrating from Paradox/BDE app to SQL Server.
Up until now, we've used Delphi 7 calls to UCrpe.pas for Crystal Reports 8.5 and its VCL viewer. These of course are long since unsupported, but we need to continue using them for the time being.
We are able to use the CR Designer's Set Location to connect to SQL Server while in the CR Designer. We can then edit and view reports based on SQL Server data perfectly (which really amazes us, given how old this tool is.)
But, in the shipping product we need to connect to the SQL Server at run-time from Delphi rather than in the CR Designer. (Since customers will have different connection strings and perhaps even different database names.)
In the past, to "connect" to Paradox tables, at runtime in Delphi 7 we set Tables[TableIndex].Name and .Path to the Paradox table and then eventually did an .Excute.
We haven't been able to figure out the calls to make to replace the above .Name and .Path assignments with a connection string to a SQL Server using Windows Authentication.
We've examined UCRPE32.pas (all 50,000+ lines!) and techref-CRPE32 reference.pdf (all 700 pages!) and are lost. Do we have to connect each table if there is more than one? Are there special dll's we have to reference explicitly? How do we specify Windows Authentication vs SQL Authentication? etc.
There is TCrpeLogOnInfo, TCrpeLogOnServerItem, etc., etc.
Can anyone show us some sample code to login and connect from D7 via UCRPE32.pas
two tables (via Windows or SQL Authentication... both needed at different times.)
TIA

Delphi - remote data module list of active connections?

I have a Delphi-based client-server application. The server is a fairly simple application with a TRemoteDataModule. The client application connects to it via a TSocketConnection.
Everything is working fine on that front.
Is there a way to access the list of currently active connections for the TRemoteDataModule?
The reason I'm asking is because I would like to prevent users from connecting from more than one machine at a time to the same server, so I figured I would keep a list of usernames per connection and check against it whenever a new connection is attempted, or beforehand, client-side, via a a COM function.
Or should I be using some other mechanism altogether?
As an aside, is there a way to see which threading model and instancing model were used when creating the RDM? I'm not the one who created it, and I don't know where to find that.
Cheers!
Using Delphi XE5, if that makes a difference

Concrete5: How to access external asp.net database?

I am working on a project where I need to access external database (asp.net) for some content and display the content on Concrete5. How can I achieve this?
concrete5 uses the ADOdb php library. I'm assuming your asp.net application uses mssql.
http://phplens.com/lens/adodb/docs-adodb.htm#connect_ex
Scroll down a bit and you will get to the mssql part.
Are you asking how to connect to the database? Or how to take that data and display it on your concrete5 site?
Connecting to the database has nothing to do with concrete5 -- instead just google for "connect to SQL Server database from PHP" (or use ADODB as #mkly points out in his answer).
But if you are asking how to display the content, then the easiest way to do that is by creating a single_page -- see http://www.concrete5.org/documentation/developers/pages/single-pages

Connecting to external database in iOS

I know I can use SQLlite and of course a clientdataset, but....
How do I connect to an external database over the internet in iOS using Firemonkey?
There's a blog page on EDN here, it uses a non-visual datasnap library:
http://edn.embarcadero.com/article/41729
Link to the source code: http://cc.embarcadero.com/item/28579
The example connects to a remote Interbase, server, but it should be fairly easy to rewrite it to use other databases like MySQL.

Why doesn't Microsoft support OLE DB connections to SQL Azure?

At the MSDN website it says, "Connecting to SQL Azure by using OLE DB is not supported."
There are other places on the web where folks report that it works fine for them after tweaking the server name in the connection string, such as here and here. Even SQL Server's Analysis Services uses OLE DB to connect to SQL Azure!
I develop a native/unmanaged application in Delphi that connects to SQL Server using ADO through the OLE DB provider for SQL Server. I'm considering adding SQL Azure support. It would be really helpful if I could reuse the majority of my code without not too much change. I probably wouldn't consider going this direction otherwise.
It would be helpful if Microsoft were more clear on why "OLE DB is not supported". If there are certain limitations within the use of OLE DB, what are they? Maybe I can work around them, or maybe it wouldn't affect me.
Microsoft also mentions that ODBC is supported. So could I use the "OLE DB provider to ODBC" and connect this way? Or is any combination that includes OLE DB "not supported"?
You can use it, however it has not been thoroughly tested for all cases. Essentially, it should work for most things, but there might be a few edge cases where it won't work. Until we document those cases, it remains unsupported. That being said, if you were to use and run into errors, we would love to know about it and prioritize that to be fixed.
Vote for the OleDB support for Azure here:
http://www.mygreatwindowsazureidea.com/forums/34685-sql-azure-feature-voting/suggestions/407269-ole-db-provider-for-connecting-to-sql-azure?ref=title
You can use ADO using the SQL Native Client although this information is hard to find you can read about it here http://msdn.microsoft.com/en-us/library/ms130978(SQL.110).aspx and here http://msdn.microsoft.com/en-us/library/ms131035(SQL.110).aspx.
In the connection string instead of using Provider=SQLOLEDB; we can use Provider=SQLNCLI10;. Also it is recommended to use DataTypeCompatibility=80;. So a SQL Native Client supported connection string would look like this:
"Provider=SQLNCLI10;Server=tcp:MyServerName.database.windows.net;Database=AdventureWorks2008R2;Uid=MyUserName#MyServerName;Pwd=MyPa$$w0rd;Encrypt=Yes;DataTypeCompatibility=80;"
You can also add "MARS Connection=True;" to the connection string for multiple recordsets.

Resources