This is a mirror of official site: http://jasper-net.blogspot.com/

Working with Sybase Databases using ADO.NET

| Monday, March 22, 2010
You can access a Sybase database using the OleDb data adapter provider. The only thing you need to do is to set up an ASO OLE DB provider data source. As you can see from listing 11-12, I created a data source called sydev with the user ID tiraspr and the password tiraspr. After creating a connection, you use the same steps to access the database as described previously. I selected data from the user_tree_start table and used it to create a command object. After that I called ExecuteReader to execute the string and fill data in a reader.

Listing 11-12: Accessing a Sybase database

using System;
using System.Data;
using System.Data.OleDb;

namespace AccessSybase
{
   class Class1
   {
       static void Main(string[] args)
       {
           string connectionString, sql;
           OleDbConnection conn;
           OleDbDataReader rdr;
           OleDbCommand cmd;
           connectionString =
           "Provider=Sybase ASE OLE DB Provider;Datasourcce=sydev;" + "User ID=tiraspr;Password=tiraspr";
           conn = new OleDbConnection(connectionString);
           conn.Open();

           sql = "Select * from user_tree_start";
           cmd = new OleDbCommand(sql, conn);

Read more: C# Corner

Posted via email from jasper22's posterous

0 comments: