Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

.NET Data Providor

3 posts in General Discussion Last posting was on 2009-01-07 03:00:30.0Z
Simon Posted on 2008-12-31 13:42:18.0Z
Sender: 7898.4958e33a.846930886@sybase.com
From: Simon
Newsgroups: ianywhere.public.general
Subject: .NET Data Providor
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <495b76ba.6f17.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 31 Dec 2008 05:42:18 -0800
X-Trace: forums-1-dub 1230730938 10.22.241.41 (31 Dec 2008 05:42:18 -0800)
X-Original-Trace: 31 Dec 2008 05:42:18 -0800, 10.22.241.41
Lines: 48
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7301
Article PK: 5514

I am having a problem deploying a application written using
.NET Data Providor. My SQL Anywhere version is 10.0.1.3788.
The documentation (under SQL Anywhere Server - Programming)
is very confusing and does not work.

1. At the destination computer (.NET Framework 1.1, 2.0
installed, XP with SP3) should I need to create a
C:\MyApp\Assembly\v2 to store iAnywhere.Data.SQLAnywhere.dll
file.

DOC says: "If you are deploying the .NET Data Provider, you
must register the .NET Data Provider DLL
(install-dir\Assembly\v2\iAnywhere.Data.SQLAnywhere.dll)
using the gacutil utility that is included with the .NET
Framework."

2. I was able to get it working having application, SQL
Anywhere files and iAnywhere.Data.SQLAnywhere.dll on the
same folder. But I do not want to keep my application on SQL
Anywhere folder.

3. DOC Says: "Visual Studio .NET deploys the .NET Data
Provider DLL (iAnywhere.Data.SQLAnywhere.dll) to your device
along with your program. If you are not using Visual Studio
.NET, you need to copy the Data Provider DLL to the device
along with your program. It can go in the same directory as
your application, or in the Windows directory."

I am using Visual Studio .NET 2005. I had
a. C:\MyApp\Assembly\v2\iAnywhere.Data.SQLAnywhere.dll
registered with gacutil
b. C:\MyApp\win32\All SQL Anywhere files and registered with
regsrv32.
c. C:\MyApp\my Application.exe

Then it gave an error such as Language-resource library
dblgen10.dll cannot be found. I have registered them and
everything else working fine. Only problem is my app that
use .NET providor.

Then it gave me an error r

4.SAConnection conn = new SAConnection(
"Data Source=SQL Anywhere 10 Demo;UID=DBA;PWD=sql" );
This is a sample code on the documentation. "SQL Anywhere 10
Demo" is the DSN. This mean even this like Microsoft OLEDB
depends on ODBC. Can I avoid ODBC and connect directly to
SQL Anywhere dbsrv.exe via locally or network.


Dietrich Posted on 2009-01-06 14:59:19.0Z
Subject: Re: .NET Data Providor
From: Dietrich <Dietrich@ianywhere.sybase.germany>
Content-Type: multipart/mixed; boundary=----------qK4YMm9eXlb7EDxR7mq4Bz
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
References: <495b76ba.6f17.1681692777@sybase.com>
Message-ID: <op.uncbw41foacwen@dlauterxp>
User-Agent: Opera Mail/9.63 (Win32)
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 6 Jan 2009 06:59:19 -0800
X-Trace: forums-1-dub 1231253959 10.22.241.152 (6 Jan 2009 06:59:19 -0800)
X-Original-Trace: 6 Jan 2009 06:59:19 -0800, vip152.sybase.com
Lines: 201
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7305
Article PK: 5516

Hi,

in the attached document I have described steps how-to simply deploy a
.NET application. Only a simple example.

With your references to the documentation it looks indeed a like bit
confusing. Basically you were refering to two different scenarion
a.) in which the assembly should be registered
b.) in which the assembly is in the same directry as the application
The approach is different.
The scenario a.) guarantees that any application, using .NET 1.1 or 2.0,
can use the .NET Data Provider from SQL Anywhere. The deployment of the
SQL Anywhere client components can be done separately from the application
that is going to use the provider.
The scenario b.) is useful when you develop an application, in a specific
.NET environment (1.1 or 2.0). You know that for 99% only your application
will use the data provider. You deploy .NET Data Provider from SQL
Anywhere together with your application.


You run into the problem with the "missing language-resource libary,
because
1.) the dll wasn't in the working directory
2.) directory (where the dll was stored) wasn't in the PATH
At the time your client application tried to load the data provider, the
provider tried to load the needed dll based on the standard mechanism that
SQL Anywhere uses. See SQL Anywhere® Server - Database Administration >
File Locations and Installation Settings > How SQL Anywhere locates files


As you can see from the attached sample, it is not needed to define a ODBC
Data Source. You can use the standard connection parameters to help the
client to find the database server.


Kind regards,

dietrich

On Wed, 31 Dec 2008 14:42:18 +0100, <Simon> wrote:

> I am having a problem deploying a application written using
> .NET Data Providor. My SQL Anywhere version is 10.0.1.3788.
> The documentation (under SQL Anywhere Server - Programming)
> is very confusing and does not work.
>
> 1. At the destination computer (.NET Framework 1.1, 2.0
> installed, XP with SP3) should I need to create a
> C:\MyApp\Assembly\v2 to store iAnywhere.Data.SQLAnywhere.dll
> file.
>
> DOC says: "If you are deploying the .NET Data Provider, you
> must register the .NET Data Provider DLL
> (install-dir\Assembly\v2\iAnywhere.Data.SQLAnywhere.dll)
> using the gacutil utility that is included with the .NET
> Framework."
>
> 2. I was able to get it working having application, SQL
> Anywhere files and iAnywhere.Data.SQLAnywhere.dll on the
> same folder. But I do not want to keep my application on SQL
> Anywhere folder.
>
> 3. DOC Says: "Visual Studio .NET deploys the .NET Data
> Provider DLL (iAnywhere.Data.SQLAnywhere.dll) to your device
> along with your program. If you are not using Visual Studio
> .NET, you need to copy the Data Provider DLL to the device
> along with your program. It can go in the same directory as
> your application, or in the Windows directory."
>
> I am using Visual Studio .NET 2005. I had
> a. C:\MyApp\Assembly\v2\iAnywhere.Data.SQLAnywhere.dll
> registered with gacutil
> b. C:\MyApp\win32\All SQL Anywhere files and registered with
> regsrv32.
> c. C:\MyApp\my Application.exe
>
> Then it gave an error such as Language-resource library
> dblgen10.dll cannot be found. I have registered them and
> everything else working fine. Only problem is my app that
> use .NET providor.
>
> Then it gave me an error r
>
> 4.SAConnection conn = new SAConnection(
> "Data Source=SQL Anywhere 10 Demo;UID=DBA;PWD=sql" );
> This is a sample code on the documentation. "SQL Anywhere 10
> Demo" is the DSN. This mean even this like Microsoft OLEDB
> depends on ODBC. Can I avoid ODBC and connect directly to
> SQL Anywhere dbsrv.exe via locally or network.

Two machines with Windows XP Professional SP3


On a machine where SQL Anywhere 10 and .NET 2.0 environment has been completely installed
- create new file "SA10employees.cs" with content (see below)
- compile SA10employees application, using command: csc "/r:%SQLANY10%\Assembly\v2\iAnywhere.Data.SQLAnywhere.dll" SA10employees.cs
- create a TRANSFER folder, which will be later copied on the traget machine
- copy the newly created application SA10employees into the TRANSFER folder
- copy the following (client) files into the TRANSFER folder
%SQLANY10%\Assembly\v2\iAnywhere.Data.SQLAnywhere.dll
%SQLANY10%\win32\dbcon10.dll
%SQLANY10%\win32\dblgen10.dll
- copy the following (server) files into the TRANSFER folder
%SQLANY10%\win32\dbsrv10.exe
%SQLANY10%\win32\dbsrv10.lic
%SQLANY10%\win32\dbserv10.dll
%SQLANY10%\win32\dbctrs10.dll
%SQLANY10%\win32\sqlany.cvf
%SQLANY10%\win32\dbicu10.dll
%SQLANY10%\win32\dbicudt10.dll
- copy the demo database into the TRANSFER folder
- transfer the TRANSFER folder to the target machine


On the target machine .NET 2.0 environment has been completely installed
- create a new folder SERVER
- copy the following (server) files from the TRANSFER folder into the SERVER folder
dbsrv10.exe
dbsrv10.lic
dbserv10.dll
dblgen10.dll
dbctrs10.dll
sqlany.cvf
dbicu10.dll
dbicudt10.dll
<demo database>
- open a DOS box and run the following commands
SET SQLANY10=<SERVER folder>
SET ASLANG=EN
SET PATH=<SERVER folder>;%PATH%
<SERVER folder>\dbsrv10 <SERVER folder>\demo
=> database server is started
- create a new folder CLIENT
- copy the following (client) files from the TRANSFER folder into the CLIENT folder
SA10employees.exe
iAnywhere.Data.SQLAnywhere.dll
dbcon10.dll
dblgen10.dll
- open a DOS box and run the following commands (1
CD < CLIENT folder>
SA10employees
=> result output showing content of table Employees
- in the open DOS box for the client run the following commands (2
MKDIR DB
CD DB
MOVE ..\dbcon10.dll .
MOVE ..\dblgen10.dll .
MOVE ..\iAnywhere.Data.SQLAnywhere.dll .
SET PATH=C:\PGM\CLIENT\DB;%PATH%
<TARGET folder>\gacutil /i iAnywhere.Data.SQLAnywhere.dll
CD ..
SA10employees
=> result output showing content of table Employees


(1 scenario for having client application and SQL Anywhere .NET client files in a single directory
(2 scenario for having client application and SQL Anywhere .NET client files in separate directories



=== SA10employees.cs ===
using System;
using System.Data;
using iAnywhere.Data.SQLAnywhere;

class SA10employees
{
public static void Main(string[] args)
{
SAConnection conn = new SAConnection( "ENG=demo;UID=dba;PWD=sql" );

Console.Write("try to connect ...");
try {
conn.Open();
Console.Write("connected");

SACommand cmd = new SACommand( "SELECT GivenName, Surname FROM Employees", conn );
SADataReader reader = cmd.ExecuteReader();
while( reader.Read() ) {
Console.WriteLine( "{0} {1}", reader.GetString( 0 ), reader.GetString( 1 ) );
}

conn.Close();
} catch( SAException ex ) {
Console.Write( ex.Errors[0].Message );
}
}
}