asp page odbc connection - asp-classic

I have an asp page which brings data from DB through ODBC connection, but it's failing. The stored proc is defined in the asp page which brings the data, SP seems to be fine but data is not coming.

Post the error, blur your passwords (hope that box isn't exposed.)
Your error is likely a missing ODBC driver. Check whether your sites AppPool is running 32 bit or 64 bit, then check the respective ODBC Manager to see if the driver you are using exists on the machine. If not go download one for whatever database server you are using and install it.
If you have windows 8+ or 2012 Server + on the server, just use the start screen search to find the ODBC managers, can't remember their run commands, and their difficult to find in the UI, I don't even remember where they are.
This commonly happens when people switch their app pool from 32 bit to 64 bit in a server upgrade, or just to run 64 bit. There are two versions of ODBC drivers, one 32 and one 64 bit. If you don't have the 64 bit ODBC driver and switch the app pool to 64 bit, your DB access will time out or fail. ASP commonly has "On Error Resume Next" all over the place, so might be eating the error and showing something generic instead.

I have sorted out this issue.Commented out the ODBC section and created a new SQL connection string directly in the asp page-
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
"Provider=SQLOLEDB;Server=SERVER\INSTANCE;Database=DBName;UID=*;PWD="

Related

Unable to use .accdb as a datasource for report builder even though connection test is successful

I am trying to set up an .accdb as a datasource on the reporting server. The database is local on the server and I have followed all the instructions to create a 32 bit and a 64 bit ODBC connection for .mdb and .accdb. I set up the data source on the Report Manager site as ODBC with dsn=dbname and test the connection and it is successful.
From the Report Manager site, I open a report in Report Builder. I add a dataset and point to the shared connection. Test connection is successful.
I create a new data set based on this data source and click Query Designer and get this error: Unable to Connect to Datasource dbname. ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application.
Then I prompted for credentials. Of course nothing works there. And this particular .accdb has only Admin with no password anyway. All users can access it.
The error makes me think there's a 32 bit vs 64 bit conflict. The .accdb is 32 bit, but Report Manager only sees it with the 64 bit connection, then tanks when I try to create the data set.
I've set the same odbc connections up on my local machine and on the server. Still no dice. Any and all help would be appreciated.
I kept working on this and was able to create a data source with the following connection string:
Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=\server\path\database.accdb;Uid=Admin;Pwd=;
I edited the report and used query builder to test the query and results. Query builder allows me to see results. Yay! Progress!
But now when I preview/run the report I get the following:
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'dataset1'. (rsErrorExecutingCommand)
For more information about this error navigate to the report server on the local server machine, or enable remote errors.
Any ideas?
I was able to make this work. I had to install the 32 and 64 bit drivers on both the reporting server and the local (editing) machine. I created identical DSNs (32 bit and 64 bit) on each machine. Then set up the datasource with an OLE DB connection string.
Once complete, I was able to write reports against the database (but not browse tables). Other users could access the report from their own machines without the ODBC connections or drivers installed.
We'll call this a win. On to the next problem.

using a 32bit Oracle ODAC driver on 64bit SQL connection

I have an ODAC 32bits driver installed on my server, the 64 version doesnt work for me for whatever reason.
So i have to use this 32bit driver, which works just fine on my asp.net application... but now i cant use it to connect via sql server.
I need to make a shceduled task to extract data every day from an oracle database.
The idea here is make an SQL Job to extract said data. From my understanding i need a linkedserver to said Oracle database.
I have the linked server created, which is the following:
exec master.dbo.sp_MSset_oledb_prop 'ORAOLEDB.Oracle', N'AllowInProcess', 1
exec master.dbo.sp_MSset_oledb_prop 'ORAOLEDB.Oracle', N'DynamicParameters', 1
exec sp_addlinkedserver N'UT', 'Oracle', 'ORAOLEDB.Oracle', N'//xxx.xxx.xxx.xxx/', N'FetchSize=2000', ''
exec master.dbo.sp_serveroption #server=N'UT', #optname=N'rpc out', #optvalue=N'true'
exec sp_addlinkedsrvlogin #rmtsrvname='UT', #useself=N'FALSE', #rmtuser=N'xxxxxx', #rmtpassword='xxxxxx'
When it tries to connect it gives me the following error though:
El proveedor OLE DB de 32 bits "ORAOLEDB.Oracle" no se puede cargar en proceso en un servidor SQL Server de 64 bits.
Translated:
The OLE DB provider of 32 bits "ORAOLEDB.Oracle" can not be loaded on process in a SQL Server of 64 bits.
I dont know what to do from here, and im not even sure if this is the best solution for my needs either.
I dont have access to the external Oracle DB itself, only a connection string.
Any suggestions?
Try using the OPENROWSET function. This differs from using a linked server in that the connection is made on the fly - the command requires connection information to be included in the call. The command can be fairly complex, so see the BoL documentation on the function for full details.

Oracle 12 Client odbc empty TNS

I have installed an oracle 12 Client on a windows 8 computer and on a windows 7 computer.
Using sqlplus I can connect to my database. Also the tnsping shows the right tns.
But when I try to set an odbc connection the TNS list is empty.
If I try to type the tns connection the test works, but when I try to launch my program from visual studio 2013 I get a general connection error.
I've already tried the fixes I could find on the internet (like checking that I have the 64 bit client and the 64 bit app, making a TNS_ADMIN environment variable set).
Mostly I'm wondering about the odbc problem.(this app is not using this type of connection, but I'm considering it - if I can be sure there are no problems).

Is it possible to programmatically get the server details from an ODBC DSN?

I'm working on some issues with psqlODBC's XA/MSDTC transaction handling and I find myself needing to obtain the server connection details (hostname, port, etc) from any user-supplied dsn programmatically without having psqlODBC invoked via the Driver Manager to do so.
Just parsed key/value string pairs will do; the problem is resolving user/system/file DSNs to get the underlying connection info.
The underlying issue I'm trying to solve is that a 32-bit application using MSDTC on a 64-bit system will supply a DSN that works for the 32-bit PostgreSQL driver. The 64-bit PostgreSQL drivers have different names - PostgresSQL ANSI vs PostgreSQL ANSI(x64) and similar for the Unicode drivers. So a DSN that works for a 32-bit app won't work for 64-bit apps ... like msdtc.exe. So I need a way to get the connection parameters the 32-bit app used and feed them into the 64-bit ODBC driver (or direct to libpq).
In the case of a DSN-less connection string like:
DRIVER={{PostgreSQL ANSI}};SERVER=127.0.0.1;PORT=5432;DATABASE=SOMEDB;UID=Administrator;PWD=;CA=disable"
I could just parse it to get the relevant info, but that won't work for file, system, or user DSNs where the XA transaction co-ordinator used by MSDTC only gets whatever the original user app passed to the ODBC layer - like:
DSN=SomeUserOrSystemDSNName
or
FILEDSN=C:\SomeFileDSN.dsn
and wrapped in that DSN is a DRIVER={{{PostgreSQL ANSI}}.
I've taken a look at the ODBC API docs and I don't see anything that seems to expose a way to load any DSN string, resolve file/system/user DSNs and get a parameter hash/map. OTOH, there's a lot of documentation out there, and some of the sections and function names aren't what I'd call predictable.
So - please tell me I'm missing something obvious, and there's a way to just:
GetDSNProperty("FILEDSN=C:\SomeFileDSN.dsn", "SERVER");
.. rather than writing hacky code to manually look up each DSN type.

ODBC connection failure in MS Access

I have a problem with my ODBC connection in MS Access.
Here's the strange part,we have a shared MS Access Database and everything work so fine in the other computer but not in mine. As I check my MSJET version, its 4.0.9511.0. Does it matters?
This happens when I run one of the queries.
How am I going to solve this issue? Thanks.
Some ODBC connections pass the username of the active windows user, and if that is the case, one user may be authorized while the user you copied it to may not be. Try copying the ODBC connection string up so we can see what it looks like.

Resources