Handling a SQL Server Login error msg with VBA? - sql-server

I'm working in a VBA module for Access that queries linked tables, generates reports based off the data, and then uses a PDF printer to save the reports to disk. There's a timer in the primary form that will, every N seconds, run an Access query against a "JOBQUEUE" table to see if there are new jobs.
If the database server becomes unavailable, this operation will of course time out. The run-time error of 3051 is being logged, and the loop will try to continue. The loop can't finish, however, because the following error comes right after the VB Run-Time error;
Title is "Microsoft SQL Server Login", so it's not within VB as far as I can tell.
Connection Failed:
SQLState: '01000'
SQL Server Error: 53
[Microsoft][ODBC SQL Server Driver][DBNETLIB][ConnectionOpen(Connect()).
Connection Failed:
SQLState: '08001'
SQL Server Error: 17
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not
exist or access is denied.
In every forum & discussion I've found that mentions this error, the asker is concerned with the cause of the error. In this case, I can assume that the error is temporary, and that it needs to continue trying to connect because the installation is unattended. Access goes into a "Not Responding..." state when it's timing out against the DB, and that's OK too, if connection is restored before it goes into the MsgBox described above, it will pick up where it left off and soldier on.
Does anyone know of a way that I can either mute that msgbox, preferably programatically, but I'd take anything at this point that can be done remotely that isn't an RDP session.
Edit: Link to image

The error I was getting was indeed not a run-time error that could be caught from code. Rather, it was SQL timing out after I already swallowed & dismissed time-outs in run-time in my VBA module.
The error does not seem to ever appear now that I have introduced a new timer that resets the loop that runs a query against my linked tables. It can't be logged & swallowed, but it can be prevented by being smarter about how I handle timeouts in run-time.

Related

Linked Server Test Connection Not Working (SQL Server to Oracle Database)

Database Versions:
SSMS: 17.9,
Oracle: 19.3
We are trying to establish a linked server connection to our production Oracle DB (hosted by another team) that uses SSL. The LS was created, however our test connection attempts always return this:
Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "CDWRP201_TCPS". OLE DB provider "OraOLEDB.Oracle" for linked server "CDWRP201_TCPS" returned message "Error while trying to retrieve text for error ORA-28759". (Microsoft SQL Server, Error: 7303)
I read that this meant "failure to open file" and could be caused by insufficient wallet permissions so I gave our users full access to the files (not sure if this is recommended). I did the same for the ewallet, ORA files, and even their parent folders but still no success.
What's weird is that test connections work for our non-SSL connections, which use the same tnsnames.ora file. We have no problems connecting to the Oracle DB using tnsping and sqlplus as well.
I'm struggling with this because my experience with Oracle and SSMS linked servers are few to none and feel like I've hit a dead end. Any direction you can give will be very much appreciated. I'm happy to provide more details if needed.
Thank you very much.
You actually have TWO problems.
First, your call to oracle returned ORA-28795. AS others are focusing on, that results from a failure to open a wallet. However, rather than looking for permissions issues, I'd note the second error ...
The "Error while trying to retrieve text for error" indicates that your ORACLE_HOME (for the oracle client being used my msssql) is not correctly set. When the call received the ORA-28759, it needed to find the error message file to be able to properly report it. But with improper ORACLE_HOME it was unable to locate the message file.
And it very well might be the case that the invalid ORACLE_HOME is also the root cause of the ORA-28759. I've not much expderince with walllets, but it seems reasonable that it needs ORACLE_HOME to locate the wallet, just as it needs it to locate the message file ... and a bunch of other stuff. In any event, get ORACLE_HOME set correctly and you will get more informative diagnostics/error messages on your ORA-28795.
You said yourself that "The only variable that indicated Oracle was our PATH". You need to also set ORACLE_HOME. If your oracle PATH is 'C:\Oracle\x64\product\19.0.0\client_64\bin', then your ORACLE_HOME should be 'C:\Oracle\x64\product\19.0.0\client_64'

SQL Server runs out of internal resources producing query plan

I'm having issues using Visual Studio 2019 to publish a database project to a target server where the database does not yet exist. During the publish process, the following error happens:
(46075,1): SQL72014: .Net SqlClient Data Provider: Msg 8623, Level 16, State 1, Line 14 The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
(46062,0): SQL72045: Script execution error. The executed script:
The error does not appear to be related to specific SQL as the error message would suggest. If I comment out a script that generates the error, the error shows up in the next script in the sequence. Overall, the publish script produced by VS2019 is approximately 72k lines. The error pops up after approximately 46k lines.
EDIT:
Server details:
SQL Server 2019 Developer edition (15.0.2000.5). 4 processors, 16 gb memory
This was my system having the problem that Anthony posted about for me. We've now figured out the cause. The root cause was a post deployment script to populate a table with initial values. The script uses a reasonably complex merge statement and tried to insert about 18,500 rows of data.
We were thrown off initially because the error output pointed to a different script in the set, not the one causing a problem. Evidently just what was in the error buffer when it burped.

SQL Server 2008: Error creating window handle

I have N number of tables in my database, which holds around 0.6 million records. I've created a SQL script which copies this data into same tables (basically it's a script to generate more data). I've tested the script it runs fine for small data (10k records). When I tried it to copy all data, it throws an error:
An error occurred while executing batch. Error message is: Error creating window handle.
1.What is the meaning of this error in SQL Server?
2.Does it has to do anything with my SQL in script, or is this cause of other component of SQL Server?
Handles are Windows tools to manage OS resources. When some app on your machine have memory leaks - you can run out of handles and this error occurs. Current state of handles can be seen in Task Manager (Handle Count)
As said in comments - it's a client side issue. For example large resultsets/query output to grid may end up to this error.
Solution: Reboot your PC, minimize the output of query. Also you can try to launch script via SQLCMD.
You can read more about it here.
Some explanation here.

Another ODBC Call Failed Topic

I am running Access 2010 FE and SQL Server 2005 BE.
I can execute pass through queries to my SQL Server succesfully by using DSNless connections.
During my testing phase sometimes I need to restore my database to get back to my original records so I can rerun my pass through queries. What I have found is when I run a pass through query, it creates an active connection on my SQL Server. I see the connection via the SQL Server Management Console under the MANAGEMENT | SQL Server Logs | Activity Monitor, select view processes. There I can see which process ID is being used and who is using it when I run my pass through query.
Now the only way for me to restore my database is to KILL the PROCESS e.g. Active connection
Now when I have my restored database in place and re-run the pass through query, I receive a ODBC -- Call Failed message box. I have attempted to run a procedure to refresh my querydefs but to no avail, I will still get the ODBC-- Call Failed message box when I click on those objects.
Now there are two options on how to fix this problem, which in either case I find not USER Friendly.
Restart my Access Application
Wait approx 5-10 minutes to rerun the Pass Through Query
I created a function to trap my ODBC Errors and this is what appears:
ODBC Error Number: 0
Error Description: [Microsoft][ODBC SQL Server Driver]Communication link failure
ODBC Error Number: 3146
Error Description: ODBC--call failed.
So if for some reason, I need to restart my SQL server or kill a process (Active Connection) on my SQL server while the Access Application is currently connected via ODBC, the objects created via ODBC will not perform properly till I execute the 2 workaround solutions as stated above.
Can anyone shed some advice on a solution? I appreciate any insight.
I asked a similar question some time ago, and never got a satisfactory answer. My original question is here: Force SET IDENTITY_INSERT to take effect faster from MS Access
There is a registry setting documented here for ACE that controls the timeout behavior:
ConnectionTimeout: The number of seconds a cached connection can remain idle before timing out. The default is 600 (values are of type REG_DWORD).
So as a third workaround (in addition to the two you already listed) you can change that registry setting to a shorter timeout (like 10 seconds). This is the approach I took in my answer. One caveat is that shortening the timeout may cause performance or other issues. Your mileage may vary.
See my full answer to the original question for more info.

SSIS: transaction during simultaneous moving of data

I implemented SSIS package which moves data from Sql Server database to another one. This package has set of Data Flow Tasks which copy data simultaneously in different tables. Each Data Flow Task contain OLE DB datasource and Sql Server destination.
Package worked fine until I decided to implement transaction. I found that it is not possible to just set TransactionOption to Supported on package level, because SSIS cannot handle transactions in multiple simultaneous processes. So, I decided to use this way:
http://consultingblogs.emc.com/jamiethomson/archive/2005/08/20/SSIS-Nugget_3A00_-RetainSameConnection-property-of-the-OLE-DB-Connection-Manager.aspx
But now I have another problem. I have "Unable to bulk copy data. You may need to run this package as an administrator" errors. These errors occur in random places. For example if I ran package in the first time Data Flow Task named "Task A" can be executed correctly, but when I run package in the second time it can throw the error.
How do I can implement transaction in my case? (Changing of package in order to perform execution of Data Flow tasks sequentially is not an option)
I got a recent error with our MS SQL Server 2008R2 and SSIS. Found the error:
[SQL Server Destination [16]] Error: Unable to bulk copy data. You may need to run this package as an administrator.
[SSIS.Pipeline] Error: component "SQL Server Destination" (16) failed the pre-execute phase and returned error code 0xC0202071.
but could not solve it with running as Admin. The error only came with one step and I finally found out that I get rid of the error when I increased the timeout of the SQL Server Destination. Funny is that with the read of external ADO NET Source I get a proper error that helped me to see the timeout is the problem.

Resources