Newbie Database in C# Qsn - Help

  • Thread starter Thread starter Ash
  • Start date Start date
A

Ash

Hi,

I'm very new to C# and OO, and am currently working on a very simple
solution with two projects in it using VStudio.NET 2003.

The first project in the solution is a Windows Application, and the
Second one is the class Library. The class library contains
constructor, which takes a connection string, and a select statement,
which make the conection, and fill the data adapter.

Assuming my database (using OleDB to Access) has a table called
"Customer" and has fields: "FirstName" and "LastName", here is the
code i have for the constructor on my class library

private string OleDbConnectionString;
private OleDbConnection Connection;
private OleDbDataAdapter DataAdapter;
private DataSet dsCustomers;

// Constructor
public DbClass(string newConnectionString, string SelectCmd)
{
OleDbConnectionString=newConnectionString;
Connection= new OleDbConnection(OleDbConnectionString);

DataAdapter=new OleDbDataAdapter(SelectCmd,Connection);
dsCustomers=new DataSet();

DataAdapter.Fill(dsCustomers, "Customers");

}
..
I understand that after having filled the dataset, it should contain
data from the database. How do i get the data for, lets say, first
row? I need to be able to get that data onto the textbox on the
Windows Application, which is in the same solution.

I will also have to create a next, and previos methods, and am
clueless at the moment.

Would appreciate your help!!

Thanks,

Ash
 
Once it's filled, you can reference the data like
DataSetName.Tables[tableIndex].Rows[RowIndex];

What it sounds like you need is Databinding and a BindingContext. Google on
BindingContext and I think you'll find a bunch of examples. The
BindingContext will allow you to nagivate through back and forth in your
controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top