How to use a "sql compact " database from non .NET language? - vb6

How to use sql compact database from a non .NET program?
For example I want to access from VB6
I want to use a database populated by C# in sql compact.
I don't access c# program source to change it's database

The compact edition has an OLEDB driver so it should work with ADO.
something like this in VB6:
Set connection = New ADODB.Connection
connection.Provider = "Microsoft.SQLSERVER.CE.OLEDB.3.5"
connection.Open "C:\FileName.sdf"

Related

OLEDB, ODBC, Ntext and Nvarchar(max)

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.

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.

RDO to ADO.NET - rdoErrors in Oracle

I am converting some code from VB RDO (using an ODBC cursor) to ADO.NET
Some of the old VB code loops through the RDO errors collection to get any ODBC or Server errors and log them accordingly.
I've converted the code using Data.Common objects (ex: DBCOnnection, DBCommand) and using Datasets and ODBC. (I am NOT using Oracle .NET Provider)
What is the best way to approach this scenario? How do I get server or ODBC errors in this fashion. There is no errors collection I can use. Should I be using Try/Catch? Any best practices? or knowledge from experience?

Linq dbml interchangeable between SQL Editions

I have a Desktop application that uses Linq To SQL as the DAL. It accesses a local SQL Express DB.
If I have a SQL CE DB that has the Exact same schema(table structure) can I re-use the generated dbml with just giving it a different connection string?
This article on LINQ To SQL on SQL CE from Matt Manela suggests that you could replace your SQL Server Express connection string with a connection string to SQL Server CE without any large issues. If it's just table-level querying that you're interested in, it sounds like you'll be in good shape.
He points out though, that CE handles connections differently than the larger SQL Server editions.
Without having tested it myself, I'd only want to determine if LINQ To SQL would ever generate any TSQL statements using keywords or features that SQL CE didn't support.
Also note, the current release does not support stored procedures or the XML datatype. It uses a subset of TSQL.
Best to visit the official .NET 3.5 SP1 LINQ To SQL for SQL Server Compact page at Microsoft.

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