Sybase database connection with c#

Asked

Viewed 331 times

-1

I have a Sybase database file on my machine, I want to make this database available in my application c#, how I make this Sybase database file available, and how to access this database with c#?

1 answer

2


With the "SQL Anywhere . NET Data Provider"

You can download it by Nuget and there are two versions:

To the ASA16: iAnywhere.Data.Sqlanywhere.v4. 5

For the ASA2017: Sap.Data.Sqlanywhere

Example:

SAConnection conn = new SAConnection("Data Source=SQL Anywhere 12 Demo");
conn.Open();
SACommand cmd = new SACommand("SELECT Surname FROM Employees", conn);
SADataReader reader = cmd.ExecuteReader();
listEmployees.BeginUpdate();
while (reader.Read())
{
    listEmployees.Items.Add(reader.GetString(0));
}
listEmployees.EndUpdate();
reader.Close();
conn.Close();
  • But since I make my database available, because I have the file, I’d like to know how to access it. Here you inform the date "source new Saconnection("Data Source=SQL Anywhere 12 Demo")", where in my or what I configure on my machine for this database to be accessible in my application? you would know to inform me?

  • Where I specify the path of my database?

  • Sybase SQL Anywhere is like any other managed database (Postgresql, Mysql, Mssqlserver), you need to install a server. https://www.sap.com/brazil/products/sql-anywhere.html

  • One last piece of information, if I have an odbc connection on another server already working, as I mount the connection string to access this database q is on another server?

  • In the example of the answer Data Source=SQL Anywhere 12 Demo, the SQL Anywhere 12 Demo is the ODBC DSN. You create an ODBC (yes SAP has not yet evolved) on the client machine and use the DSN in the string Connection.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.