Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Working with Sybase Databases using ADO.NET
WhatsApp
Mahesh Chand
14y
68.6k
0
0
100
Article
Working with Sybase Databases.zip
This article has been excerpted from book "A Programmer's Guide to ADO.NET in C#".
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);
cmd.CommandType =
CommandType
.Text;
rdr = cmd.ExecuteReader();
while
(rdr.Read())
Console
.WriteLine(rdr[
"user_id"
].ToString() +
" "
+ rdr[
"tree_start"
] +
" "
+ rdr[
"strategy_group"
]);
Console
.WriteLine(
"DONE"
);
Console
.Read();
}
}
}
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.
This essential guide to Microsoft's ADO.NET overviews C#, then leads you toward deeper understanding of ADO.NET.
Sybase Databases
ADO.NET
C#
Up Next
Ebook Download
View all
Printing in C# Made Easy
Read by 22.3k people
Download Now!
Learn
View all
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.
Membership not found