trigger function when ODBC connection is opend in Ms Access - ms-access

In the init phase of my ms access app, I set some links to ODBC tables in a postgresql db. I also set the application name with a statement "set application_name = ... ;".
So far it works well, but ...
After a phase of inactivity (or some other reason) the connection is closed. After accessing a linked table, the connection is reopen automatically. That is pretty cool, but ...
=> the application_name is lost.
Question: Can I use a trigger function, when ms access is opening a new connection or is there any other solution?

If you're just using linked tables, then no, unfortunately, this is not possible.
Access manages the connection internally for tables, and doesn't fire any events when reconnecting.
If you're only using forms, you can manage the connection yourself using a predeclared self-healing object. In that case you can raise events when reconnecting, and let the object set the application name.
Another half-solution is to use passthrough queries instead of tables, and start them all off with set application_name

Related

Snowflake Connection String for Microsoft Access

My company is switching from an Oracle 'on-prem' data warehouse to Snowflake cloud storage.
I support MANY Microsoft Access apps that use pass-through queries which use a simple string in the connection string property. Once a user had downloaded the appropriate Oracle Admin (X64) client, they are in business.
With snowflake, the client software is also a simple download. I am stuck, however, getting the connection string to work. Here is where I'm currently at:
ODBC;DRIVER={SnowflakeDSIIDriver};SERVER=xxxx.us-east-1.privatelink.snowflakecomputing.com;UID=xxx#xxx.com;PWD=xxx;WH=XYZ;DATABASE=XYZ;ROLE=XYZ
(This string returns error: ODBC--call failed. No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command. (#606))
Has anyone successfully managed to connect a Microsoft Access Pass-through query to Snowflake and retrieve results?
(Please note, the authenticator is not externalbrowser)
(MS Access 365 for Enterprise, 64-bit)
Optional Connection Parameters
warehouse (Warehouse)
Specifies the default warehouse to use for sessions initiated by the driver.
WH=XYZ; should rather be WAREHOUSE=XYZ;
Ok, to those who may be interested, the below works for the pass through query connection string property:
ODBC;
driver={SnowflakeDSIIDriver};
server=xxxxxxxxx.xx-xxxx-x.xxxxxxxxxx.snowflakecomputing.com;
database=xxxxxxxxxx;
warehouse=xxxxxxxxxxxxxxxx;
role=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
Uid=xxxxxxxxxxx#xxxxxxx.com;
Pwd=xxxxxxxxx;

SSIS Connection String

I have a local SQL DB and an Azure SQL DB. In my data flow I am trying to pass data from local (ole db source) to Azure (ole db destination).
I am unable to save the password for the connection string so I have parameterized the connection string of the data flow task but I seem unable to work out how to get the destination to use it?
I know this isn't best practice but I just want to prototype a few things. Is this possible?
Thanks
Double click project params and add your connection string as a parameter. Give it any name you want, select string then paste your Azure connection string that you have copied directly from you Azure portal connection string option.
This creates a project level conn string parameter.
Right click connection managers and create a new ADO.Net connection manager. This should be fairly straightforward.
Once completed, select this connection manager and add an expression to it from the property window:
In the Property Expression Editor: (1) Select a property called ConnectionString. (2) Select the elipsis beside expression. From the pop up open the project parameters in the left hand area and you will see the connection parameter you created earlier. Drag this into the expression text area. Evaluate the expression to check it works.
Click OK
You should now be able to use this as an Azure connection without getting any errors

CurrentProject.OpenConnection Fails in MS Access 2000

I support a LOB application written in MS Access VBA with a SQL Server back end. One feature of the application is the ability to open a second instance of the application, allowing the users to view/modify two records at the same time.
The first time I open the application it connects and everything works fine. However when I attempt to open the second instance I get the following error message:
-2147467259 - Method "OpenConnection" of object _CurrentProject failed.
This is the line of code executing when the error occurs:
CurrentProject.OpenConnection strConnection
I have stepped through the code and verified that strConnection is the same connection string in both the first and second instances of the application
I'm running out of things to look for. Any ideas are greatly appreciated!
UPDATE: It appears that something is not allowing the second MSACCESS.EXE instance to use the same connection string. My connection string is below, with database and server substituted for the actual database and server.
PROVIDER=SQLOLEDB.1;INTEGRATED SECURITY=SSPI;PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=database;DATA SOURCE=server
Try
MultipleActiveResultSets=True
(http://msdn.microsoft.com/en-us/library/h32h3abf(v=vs.110).aspx)
Would it be better to open a new form from the same application?
dim frm as ShowCar_Form
frm.Show

Best way to connect to database for this application

I have a Delphi application which hits a database (usually MySql) every 60 seconds through a TTimer. The application is more or less an unattended bulletin board. If the network drops the application needs to continue running and connect back to the database when the connection is back. Often it might be over broadband, so chances are the connection is not always the best.
I am using the TAdoConnection component. This is opened at application startup and remains open. Whenever I need to make a new query I set the Connection to the open TAdoConnection. But I am finding this is not very reliable if there is a network drop.
What is the best way to connect to the database in this instance?
I have seen ways where you can build the connection string directly into the TAdoQuery. Would this be the proper way? Or is this excessively resource intensive? Sometimes I need to open 5-10 queries to get all the information.
Or how about doing this in the TTimer.OnTimer event:
Create TAdoConnection
Do All Queries
Free TAdoConnection
Thanks.
You should use single TAdoConnection object to avoid setting connection string to each component. Keep your connection object closed and open it when you need to access data. Something like this:
procedure OnTimer;
begin
MyAdoConnection.Open;
try
// Data access code here
...
finally
MyAdoConnection.Close;
end;
end;
You can additionally put another try/except block around MyAdoConnection.Open to catch situation where network is not available.
About second part of your question, best would be to put all your data access components in data module that you will create when you need to run data access procedures. Then you can put all your data access code in that data module and separate it from rest of the code.
You could try to open connection in OnCreate event of datamodule, but be careful to handle possible exceptions when opening connection. Close connection in OnDestroy event. Then you can use that datamodule like this:
procedure OnTimer;
var myDataModule : TMyDataModule;
begin
myDataModule := TMyDataModule.Create;
try
// Data access code here
myDataModule.DoSomeDatabaseWork;
finally
myDataModule.Free;
end;
end;

Coldfusion Connection Code

OK, Ive got my site all up - just not working. ahah. I need (I think) the correct code for a connection string to my database etc. I'm using ColdFsuion and Mysql. My code for the connection string is as follows:
<CFQUERY
NAME="cfGossip"
DATASOURCE="mysqlcf_bridgettip"
USERNAME="<bridgettip>"
PASSWORD="<*******>"
>
</CFQUERY>
My DNS on my hosting plan is, well I think is - mysqlcf_bridgettips and on my ColdFusion is cfGossip. I'm not sure which one to use, or if it's even one of them...? It says the error is there when I try access my index.cfm page.
The error over all is :
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be
displayed.
Is it the connection string that is wrong? I would really love any help at all - rewriting my string etc.
Typically ColdFusion is easier to handle by adding datasources via the ColdFusion Administrator: See Adding Data Sources for ColdFusion.
if you cant access the coldfusion administrator and have no control panel to add a datasource you need to ask your host to add a datasource for you with a name. A datasource in this context is different from having the database created - its having the database "registered" with the coldfusion administrator so that it can be referenced via a datasource name
once the datasource is created you can hit it by adding the datasource attribute to the cfquery tag: cfquery name="myquery" datasource="mydatasourcename"
My DNS on my hosting plan is, well I
think is - mysqlcf_bridgettips and on
my ColdFusion is cfGossip.
The coldFusion Administrator should have a datasource that contains your mysqlcf_bridgettips information (CF datasource name, database name, server IP and port, username/password). If you've named that datasource cfGossip in the administrator than your cfquery should look like:
<cfquery name = "variableNameOfYourQuery (ex. qUsers)" datasource = "cfGossip">
I put my username/password in my datasource in the administrator so I don't have it written in my code.
I believe CF5 was the only version of CF that allowed DSN-less connections that would require a "connection string".