ARTICLE

Working with Sybase Databases using ADO.NET

Posted by Dinesh Beniwal Articles | ADO.NET in VB.NET June 28, 2010
In this article I will explain about working with Sybase Databases using ADO.NET.
 
Reader Level:

HTML clipboard

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
 

Imports System.Data

Imports System.Data.OleDb

 

Namespace AccessSybase

    Class Class1

        Private Shared Sub Main(ByVal args As String())

            Dim connectionString As String, sql As String

            Dim conn As OleDbConnection

            Dim rdr As OleDbDataReader

            Dim cmd As OleDbCommand

            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)

            cmd.CommandType = CommandType.Text

            rdr = cmd.ExecuteReader()

 

            While rdr.Read()

                Console.WriteLine(rdr("user_id").ToString() & " " & Convert.ToString(rdr("tree_start")) & " " & Convert.ToString(rdr("strategy_group")))

            End While

 

            Console.WriteLine("DONE")

            Console.Read()

        End Sub

    End Class

End Namespace

 

Conclusion

Hope this article would have helped you in understanding working with Sybase Databases using ADO.NET. See my other articles on the website on ADO.NET.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Diagram
Become a Sponsor