Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with BindingSources

Status
Not open for further replies.

thedougster

Programmer
Jan 22, 2009
56
US
I need some help with BindingSources (in C#).

This is what I'm working on:

From the C# tutorial at Programmer's Heaven (
private void btnLoadData_Click(object sender, System.EventArgs e)
{
string connectionString = "server=P-III; database=programmersheaven; uid=sa; pwd=;";
SqlConnection conn = new SqlConnection (connectionString);
string cmdString = "SELECT * FROM article";
SqlDataAdapter dataAdapter = new SqlDataAdapter (cmdString, conn);
DataSet ds = new DataSet ();
dataAdapter.Fill (ds, "article");
dgDetails.SetDataBinding (ds, "article");
}

When I try to compile this, I get the following error: "The name 'dgDetails' does not exist in the current context".

I have just been told that dgDetails is a BindingSource. I'm a newbie, so I'm not familiar with BindingSources.

Could you tell me what I need to include in my code to get the compiler to recognize the dgDetails BindingSource and compile my app?
 
A Demonstration Application for Data Grid Control
Let's create a simple application first that loads table data from a database server to the data grid control. First of all add a data grid control and a button to your form using the Visual Studio toolbox. We have set the Name property of the data grid to 'dgDetails' and its CaptionText property to 'ProgrammersHeaven Database'. The name of the button is 'btnLoadData'. The event handler for the button is:

This is the paragraph immediately above the code snippet you posted from:
[ponder][ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top