chelvis
06-16-2006, 03:40 PM
I am doing this in Visual studio 2003 and SQL Server 2000.
I created a web form with a DataGrid and then connected to a database called 'Contacts'. The database has a table called Contacts. I created a connection to the database (sqlConnection1) and a data adapter (sqlDataAdapter1) and set a DataSet (dataSet11). Follwoing is the code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Chapt05
{
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected System.Web.UI.WebControls.DataGrid dataGrid1;
protected Chapt05.DataSet1 dataSet11;
private void Page_Load(object sender, System.EventArgs e)
{
// Fill the data set.
sqlDataAdapter1.Fill(DataSet1);
// Update the DataGrid.
dataGrid1.DataBind();
}
}
}
When I compile I am getting the following error:
'Chapt05.DataSet1' denotes a 'class' where a 'variable' was expected.
Why is this error? I didnt do anything different and I am not being able to figure this out - am new to this and learning it.
I created a web form with a DataGrid and then connected to a database called 'Contacts'. The database has a table called Contacts. I created a connection to the database (sqlConnection1) and a data adapter (sqlDataAdapter1) and set a DataSet (dataSet11). Follwoing is the code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Chapt05
{
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected System.Web.UI.WebControls.DataGrid dataGrid1;
protected Chapt05.DataSet1 dataSet11;
private void Page_Load(object sender, System.EventArgs e)
{
// Fill the data set.
sqlDataAdapter1.Fill(DataSet1);
// Update the DataGrid.
dataGrid1.DataBind();
}
}
}
When I compile I am getting the following error:
'Chapt05.DataSet1' denotes a 'class' where a 'variable' was expected.
Why is this error? I didnt do anything different and I am not being able to figure this out - am new to this and learning it.