OLEDB, ODBC, Ntext and Nvarchar(max) - vbscript

I understand that Microsoft decided back in 2011 to deprecate OLE DB and that no new drivers or maintenance would occur beyond SQL Native Client V11. In future you should use ODBC based drivers - http://weblogs.sqlteam.com/dang/archive/2011/09/04/rip-ole-db.aspx
The latest ODBC driver being 'Microsoft ODBC Driver 13 for SQL Server' release on 25th July 2016 - https://www.microsoft.com/en-us/download/details.aspx?id=50420
ODBC drivers from Native Client V9,10,11 and the Microsoft ODBC Driver SQL Server V11 and 13 all work in Classic ASP code interacting with SQL server (I am using SQL 2012) except for one problem - nText and Nvarchar(max).
They just return blank - I have seen solutions saying you should read into a local variable first rather than addressing the recordset directly e.g. varStr=rs("LargeText"), but that does not work for me. And there is other mentions of using get chunk etc.
But I am quite happily using Native Client V9 (Provider=SQLNCLI) which works perfectly with these data types.
So, my questions are:
Is there anyway to get ODBC drivers working with nText/Nvarchar(max) datatypes?
Is there any benefit to using ODBC over OLEDB?
Do I have to upgade to ODBC at some stage in order to connect to SQL server in future i.e. SQL 2014/2016?
In other words, can I just carry on using OLEDB going forward?
OK, Lankymart - I would use something like this:
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Driver={SQL Server Native Client 11.0};Server=*Yourserver*;Database=*YourDatabase*;User ID=*YourUserid*;Password=*YourPassword*;"
'oConn.Open "Provider=SQLNCLI11;Server=*YourServer*; Database=*YourDatabase*;User ID=*YourUserID*;Password=*YourPassword*;"
set view=oConn.Execute("SELECT [PText] FROM [TextTest]")
ttext=view("PText")
response.write(ttext)
view.Close
set view = Nothing
oConn.Close
set oConn = Nothing
Where [PText] is an NVARCHAR(Max) field in SQL. This does not work using the native client ODBC ({SQL Server Native Client 11.0}) but will work using OLE DB (SQLNCLI11).

Did you tried to use driver={SQL Server};...? It works for me but with a issue. You need to read into a local variable because if you tried to use it again it will return null.
See the code below:
Print rs!varcharmaxVariable 'Returns ok
Print rs!varcharmaxVariable 'Returns null
...

You can change the field size from varchar(MAX) to a set size. If you cannot change the size in the database, you can cast your select statement and it will work with ODBC Driver 13.

Related

How to replicate existing OracleRDB ODBC connection in Oracle's SQL Developer application?

I am new to Oracle database in general, but I'm attempting to get Oracle's SQL Developer running on a workstation that has pre-configured System DSNs created for an OracleRDB database. I've confirmed the ODBC connections are working because I can use MS Access to connect and link to the tables. The "test" options within ODBC also succeed. Now I am trying to get a similar connection created using SQL Developer so I can see the column types and write queries in a more useful editor.
Here's what I have available when examining the ODBC connection properties:
Now I'm trying to create a duplicate connection in SQL Developer, but I'm at a loss for why things don't work. I first tried using the default SQL Developer installation, but couldn't get things working. Then I discovered there's an OracleRDB extension available, so I installed that, but I keep getting this error when attempting to use similar values:
As I stated, these ODBC connections were pre-configured on the workstation I'm using, so I don't know anything more than what is provided by the Oracle ODBC driver window.
Is there something obvious I'm not seeing or doing to replicate this connection in SQL Developer? Or perhaps something else I can do to debug this to learn more?
UPDATE
On the advice of one answer I'm trying to make the connection with JDBC, but having a hard time understanding what I'm doing wrong. Here's another screenshot with the connection parameters I have available, but with the server and database names changed:
With these values (the port came from my tnsnames.ora file), if I try to make a JDBC connection I keep getting the following error from SQL Developer:
One final attempt I did was to use the proper values in the Oracle RDB tab, and when I use them and click 'test' the Testing Connection dialog just spins and never seems to return:
So I apologize for the long post here, but I'm struggling because there's just something I am really not understanding about how this all works. I appreciate everyone who took the time to read this question.
Oracle SQL Developer is a Java Application. You'll need to get the JDBC Driver for RDB.
Once you have that, in the SQL Developer preferences, find the Third Party JDBC section, and then use that to add an entry and point to the JAR for what you just installed.
Step by step instructions here.
Working connection string for RDB Thin Driver:
RDB_DB_CONN_STR = "jdbc:rdbThin://node.myplace.com:1707/";
where node.myplace.com is the name of the OpenVMS node hosting the RDB Thin Driver, 1707 is the port number assigned to the RDB Thin Driver.

Ruby 2.0 on windows connecting to MS SQL varchar(max) truncating to 2048

background:
i have written a few ruby transformation scripts
they get data from MS SQL transform them and then store it back to the data base
i am using tiny tds gem which works over freetds
--Problem:
for columns in sql that are varchar max and have string length greater than 2048 when data is extracted using tiny tds these columns get truncated to 2048 length exactly.
Freetds protocol 7.2 does fix this issue but is not available on windows platform
the code works perfectly on a mac. but due to integration with ETL tool i have to deploy it on a windows machine.
-- does any one have a solution for this.
I don't have any code doing this myself, but have you tried using the set textsize command. I think the default is 2048.
From the MS article on Set TextSize
The SQL Server Native Client ODBC driver and SQL Server
Native Client OLE DB Provider for SQL Server automatically
set TEXTSIZE to 2147483647 when connecting.
But I think you may need to call this explicitly (using the same connection, prior to getting data).

Visual Basic ODBC AS400 iSeries crypto

I am using a ISeries Access ODBC Driver to retrieve data from a AS400.
The connection code looks something like this:
Set myConnect as new ADODB.Connection
With myConnect
.CursorLocation = adUseClient
.Provider = "MSDASQL.1"
.Open "User ID=<user>;Password=<password>;Data Source=<dsource>"
End With
This worked fine up until now.
The problem is that we have recently introduced encryption to some (ColOne) of the library columns.
A inline SQL string that used to look like this:
SELECT ColOne FROM libOne.ColOne WHERE ColOne = <val>
Now needs to look like this:
SELECT F_DecFld('FieldIdentifier',ColOne) AS ColOne FROM libOne.ColOne WHERE ColOne = <val>
I know the F_DecFld() function resides in the crypto library, I have included it in my ODBC and when I run the same query in WinSQL (Also uses the ODBC) it returns the data as expected, but from my program it returns the data without decrypting (no error).
The only thing I can think of at this point is that the Microsoft ActiveX Data Objects 2.8 Library is not taking the F_DecFld() into consideration?
Thank you.
Get an ODBC trace as per http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzaii/rzaiiodbc17.htm to see a detailed accounting of what is going on (and hopefully an error message from the driver)
crypto library needs to be added to the AS400 user profile and not just in the library list on the ODBC driver.

Logon failed, Crystal Reports 9, VB6 , sql server, sqlncli

i'm trying to build a setup package for a legacy vb6 software. the software itself connects to a sql server via sqlncli (native client). i've packaged all the dependencies and deploy them to a new machine running winxp and office2003.
now, from the target machine i can connect to the database (ms sqlserver 2005) that is running somewhere else using tcp/ip. the legacy software connects to the db just fine and i can manipulate data. but when i try to open a crystal report, things get messy:
i get an error saying "Run-time error '-2147189176(80047e48): Logon failed.
Details: 01000:[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect())"
since the reports where designed on a different system, different db and what not ... there is a loop before calling the report that resets the db-information for every table :
For i= 1 To numTables
Set crTable = crTables.Item(i)
crTable.SetLogOnInfo dbServer, dbName, dbLogin, dbPasswd
Next
the ConnectBufferString reads "Connection String=DRIVER=SQL Server;;User ID=user;;Password=;;Database=MY_DB;;Server=192.168.1.3\SQLEXPRESS;;UseDSNProperties=-1"
there doesn't seem to be a way to explicitly set the provider to SQLNCLI, at least i don't see any.
when running the software on my dev-system everything works like it's supposed to.
i hope you guys can help me out with this.
just so we don't have to argue about this : i also think both these technologies (vb6 and cr9) are outdated, but switching is not an option here.
You need to wipe the tables and change the configuration of access to the database, see the example below.
In the first line of code I put an example if necessary to change the connection driver, in my case the report was pointing to a PostgreSQL database and programativamente needed change to connect to a SQL SERVER.
myReportObject.Database.Tables(1).DllName = "crdb_ado.dll" 'Connect to SQL with OLEDB
For Index = 1 To myReportObject.Database.Tables.Count
With myReportObject.Database.Tables(Index)
.ConnectionProperties.DeleteAll
.ConnectionProperties.Add "Provider", "SQLOLEDB"
.ConnectionProperties.Add "Data Source", mySqlIP
.ConnectionProperties.Add "Initial Catalog", myDB
.ConnectionProperties.Add "User ID", usr_id
.ConnectionProperties.Add "Password", pass
.ConnectionProperties.Add "Integrated Security", 0
End With
Next
I know you said in your comment that you've got around this already, but I figured I'd throw this out there. :)
You may try using
Provider = SQLNCLI
instead of,
DRIVER = SQL Server
to see if that makes a difference.
Take a look at the following link. Scroll down on the page until you see the "SQL Native Client 9.0 OLE DB provider" section. They show examples of connections strings using the SQL Server Native Client.
http://www.connectionstrings.com/sql-server-2005
Hope this helps.

VB and Oracle connectivity

What are the steps to connect to Oracle 9i with VB6? How can I use modules and stored procedures in VB6 and how can I call an SP?
What is the method to use ADO which is helpful to insert, update, search and delete the items from the front end?
You will need ADO to connect to Oracle (add reference to microsoft activex data objects library).
You need to know where is the Oracle Instance hosted alongwith username and password?
The connection string for Oracle can be found from www.connectionstrings.com
ADODB.Connection is the one that you will need to establish the connection.
Connection has Execute method - which you can use for any insert/update/delete statements.
Now, read some documentation on ADO object library from MSDN.
And, write the code by yourself.
You can choose between the Oracle OLEDB driver (which I think comes with the Oracle client install mentioned by YogoZuno) or one from Microsoft (can't remember if it was just a standard microsoft oledb driver or one released with a nod towards oracle): in any case, the Oracle OLEDB driver is far better.
You will also need to have the Oracle client installed on your PC, along with an appropriate TNS Names file. Also, be aware that there are some minor functional differences between various versions of the Oracle 9 client - I had some issues under v9.2.0.1, that did not occur under v9.2.0.7.

Resources