Problems with Winform Datagrid

  • Thread starter Karl Beigan via .NET 247
  • Start date
K

Karl Beigan via .NET 247

Help Me please,

I'm in the process of putting together an application that willstream video into WMP (SDK version 9), based on a a userselection via a Winform datagrid. I'm using theSqlHelper.FillDataset fuction to fill a strongly typed dataset.However the problem has arrised, the the Datagrid is not beingpopulated with the datacontained within the dataset, thought thecolumns are updated to reflex it's structure. Dispite confirmingthat data is contained with the DS via using Dataset.getxml() toan textbox. Please see my code below.

Any Ideas why the datagrid doesn't see the data?

private void Form2_Load(object sender, System.EventArgs e)
{

// create a sqlconnection oject for the sqlhelper
SqlConnection DBcon = newSqlConnection(ConfigurationSettings.AppSettings["ConnectionString1"]);

try
{
DBcon.Open(); // test connection
// stored procedure name
String spEmp = "Employee";
SqlParameter [] TypeParam = new SqlParameter[0];

//connection to datasource
SqlHelper.FillDataset(DBcon,spEmp, northwind1,new string[]{"Employees"},TypeParam);
// populate textbox with ds to confirm DS has data

textBox1.Text = northwind1.GetXml();

//bind data to datagrid
dataGrid1.DataSource = northwind1.spTest123;


}

catch (SqlException ex)
{

MessageBox.Show("Can't connect to the db because, " +ex.Message);
}






}
 
A

Alex Pecoraro

I had some trouble seeing the big picture from your snipit of code. One
question is: you're binding to northwind1.spTest123 but I don't see where
you loaded data to that TableName.

Also, there's a bug in the SQLHelper that maybe causing you a problem. Check
out:

http://dotnetjunkies.com/WebLog/markbrown/archive/2003/07/16/454.aspx

Or

http://www.error-bank.com/microsoft.public.dotnet.framework.adonet/79555_Thread.aspx

Alex

Help Me please,

I'm in the process of putting together an application that will stream video
into WMP (SDK version 9), based on a a user selection via a Winform
datagrid. I'm using the SqlHelper.FillDataset fuction to fill a strongly
typed dataset. However the problem has arrised, the the Datagrid is not
being populated with the datacontained within the dataset, thought the
columns are updated to reflex it's structure. Dispite confirming that data
is contained with the DS via using Dataset.getxml() to an textbox. Please
see my code below.

Any Ideas why the datagrid doesn't see the data?

private void Form2_Load(object sender, System.EventArgs e)
{

// create a sqlconnection oject for the sqlhelper
SqlConnection DBcon = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString1"]);

try
{
DBcon.Open(); // test connection
// stored procedure name
String spEmp = "Employee";
SqlParameter [] TypeParam = new SqlParameter[0];

//connection to datasource
SqlHelper.FillDataset(DBcon,spEmp, northwind1,new string[]
{"Employees"},TypeParam);
// populate textbox with ds to confirm DS has data

textBox1.Text = northwind1.GetXml();

//bind data to datagrid
dataGrid1.DataSource = northwind1.spTest123;


}

catch (SqlException ex)
{

MessageBox.Show("Can't connect to the db because, " + ex.Message);
}






}
 
Top