Mega Code Archive

 
Categories / Delphi / ADO Database
 

Create or edit an ole-db connect string during runtime

I always wanted to find a way to edit or create an OLE-DB connect string during runtime, instead of doing it the old way by stopping an application and setting the connect string during design time and restarting the application again. Well I have found a way in doing so here is the source codes below to edit or create an OLE-DB connect string. procedure Tform1.Button1Click(Sender: TObject); begin adoCon.Connected :=false; // PromptDataSource takes the form handle and the // second pramater takes a empty string or a OLE-DB Connection string to edit. adoCon.ConnectionString := PromptDataSource(handle,edtConnection.text); adoCon.Connected :=true;// ado set to true to open the new connection end; {once the button is pressed it will bring up the Datalink form and from there you can create or edit a ole-db connection string. once you have finished with the form. the PromptDataSource function will return the connections string.}