I have a passthrough query to pull my "Active Members" from an Oracle database via an ODBC passthrough query. It works great, I can link to members retrieved by the query just like I would an Access table.
My question is, will this passthrough query automatically refresh itself each time I reference it? Or should I specify the update using VBA code? Essentially, each time a user searches for a member, I need my pass through query re-run.
No, there's no auto-refresh of pass-through queries, they're just queries stored in another db's syntax.
What I usually do is create a macro deleting rows from the existing table and running the pass-through query. If the macro introduces too much overhead, however, you could also code the steps in a function with VBA.
Related
I have 2 table, one is local named 'Client' and other is a linked table to MySQL DB in my web-server named 'ClientSql'.
When I insert data into the table Client, I want it to be insert into clientSql too. I try it with data macro (after insert), but it shows me an error saying
It's not possible in linked tables.
I have tried to create an append query successfully, and it works, but it just works if I execute it manually. My question is:
Is it possible to call it from a data macro? if is possible, can you show me how? If not, can you point me to a solution?
I'm not sure why you should be able to do it manually, but not via a macro. According to this link
http://dev.mysql.com/doc/connector-odbc/en/connector-odbc-examples-tools-with-access-linked-tables.html
you should be able to do it either way.
Another thought is to eliminate the local access client table and have the access program update the mySql table directly. However, if another program is accessing the client table at the same time, this could become tricky due to multi-user and locking situations.
I have an Access database that i need a complete dump of into Excel to import into another data source.
Is there a way i could run a SQL query using "Get External Data" function from Excel and if so what should the query look like?
Try using Microsoft Query and access Access, http://office.microsoft.com/en-us/excel-help/use-microsoft-query-to-retrieve-external-data-HA010099664.aspx. There's an option to "View data or edit Query in Microsoft Query".
This is for a SQL database, however you can use the same principal and just change the connection string to Access. Then, you would loop through the Tables collection, and within that loop you would loop through the Fields collection using something like this.
Also, have a look here and see the syntax used to loop through the Access tables collection using ADOX from Excel.
I have an access form with a list of numbers [1, 2, 3, 4, 5]. When a number is clicked on, i want to run a pass through query that opens a datasheet view of the query. So for example, say [3] is clicked, then a pass through query would run SQL like
select * from mytable where number=3
Do I have to use VBA for this? How is it done in VBA? I have the log in information for the SQL server, but no permissions other than querying tables.
You can send SQL queries to your SQL Server databases via ADO.
More on ADO: http://support.microsoft.com/kb/257819
See Also: Connecting to SQL Server over network using ADO from Excel VBA
The easiest way to achieve what you want to do is to create and save a Query in your database which you can call DoCmd.OpenQuery on.
The most efficient way to pull the data would be a pass-through query which has the predicate (WHERE element) set already (and all the connection properties as well). The challenge here is to pass the parameter (1-5) through to the saved pass-through query in a way you can call DoCmd.OpenQuery on it.
A way to do this would be to on the AfterUpdate event of the updated control that supplies 1-5, create a pass-through QueryDef (see here: https://support.microsoft.com/kb/112108) using dynamic SQL, making sure the WHERE clause represents the number you want to filter by. You'll need to set the Connect property of the new QueryDef object to have the connection string to your external db. Save the QueryDef you create, then call it by name with DoCmd.OpenQuery. This should provide you with the functionality you are looking for.
Something you actually need to do before you create the pass-through QueryDef is check for its existence and delete it if it already exists (or update its properties, I guess) or you will get an error.
Use a saved pass-though query and DAO.
You can do this for a total of 2 lines of code.
This code will work:
CurrentDb.QueryDefs("MyPass").SQL = "select * from mytable where number = " & Me.Number
DoCmd.OpenQuery "MyPass"
I have a reporting database and have to transfer data from that to another server where we run some other reports or functions on Data. What is the best way to transfer data periodically like months or by-weekly. I can use SSIS but is there anyway I can put some where clause on what rows should be extracted from the source database? like i only want to extract data for a current month. Please do let me know.
Thanks,
Vivek
For scheduling periodic extractions, I'd leave to that SQL Agent.
As for restricting the results by some condition, that's an easy thing. Instead of this (and you should always use SQL Command or SQL Command From Variable over Table Name/Table Name From Variable as they are faster)
Add a parameter. If you're use OLE DB connection manager, your indicator for a variable is ?. ADO.NET will be #parameterName
Now, wire the filter up by clicking the Parameters... button. With OLE DB, it's ordinal position starting at 0. If you wanted to use the same parameter twice, you will have to list it each time or use the ADO.NET connection manager.
The biggest question you will have to answer is how do I identify what row(s) need to go. Possibilities are endless: query into the target database and find most recent modified date for a table or highest key value. You could create a local table that tracks what's been sent and query that. You could perform an incremental load / ETL Instrumentation to identify new/updated/unchanged rows, etc.
I want to add some fake records/rows for in the table for MS SQL 2008 Standard Edition database and use these records to monitor my database.
The purpose for this is to monitor hackers. It is possible to create a trigger to do this. It seemed like the DDL Triggers can not do this tasks.
If you can't control access to your database via stored procedures (where you could add your own logging), you will need to use auditing or server-side trace for this. There is no such thing as a select trigger and there are no DMVs that will tell you which rows were looked at via any select action.