Sybase Databases using ADO.NET in VB.Net
In this article I will explain about working with Sybase Databases using ADO.NET.
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.