D
DC
Any idea why the following code is giving me the error "CS0246: The type
or namespace name 'SeminarDataAdapter' could not be found (are you
missing a using directive or an assembly reference?)"
It looks like Ive declared an instance of the OleDataAdapter object type
for SeminarDataAdapter correctly.
Any ideas?
<script language="C#" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack != true)
{
BindData();
}
}
void BindData()
{
OleDbConnection myConnection= new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\\Program Files\\Common
Files\\ODBC\\Data Sources\\seminars.mdb;");
///instantiate OleDbDataAdapter to create DataSet
OleDbDataAdapter SeminarDataAdapter = new OleDbDataAdapter("select *
from SeminarList",myConnection);
/// the following is for creating automatic command builder
OleDbCommandBuilder SeminarCmdBuilder = new
OleDbCommandBuilder(SeminarDataAdapter);
DataSet SeminarDataSet = new DataSet();
///fill the dataset
SeminarDataAdapter.Fill(SeminarDataSet, "SeminarList");
///set the dataset as a datasource for windows datagrid
datagrid1.DataSource = SeminarDataSet.Tables["SeminarList"].DefaultView;
datagrid1.DataBind();
}
void btnSave_Click(object sender, System.EventArgs e)
{
try
{
///the following statement
///inserts
///updates
///deletes for you
/// Without the CommandBuilder, this line would fail.
SeminarDataAdapter.UpdateCommand =
SeminarCmdBuilder.GetUpdateCommand();
SeminarDataAdapter.Update(SeminarDataSet);
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}
</script>
--
_______________________________________________
DC
"You can not reason a man out of a position he did not reach through reason"
"Don't use a big word where a diminutive one will suffice."
"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law
or namespace name 'SeminarDataAdapter' could not be found (are you
missing a using directive or an assembly reference?)"
It looks like Ive declared an instance of the OleDataAdapter object type
for SeminarDataAdapter correctly.
Any ideas?
<script language="C#" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack != true)
{
BindData();
}
}
void BindData()
{
OleDbConnection myConnection= new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\\Program Files\\Common
Files\\ODBC\\Data Sources\\seminars.mdb;");
///instantiate OleDbDataAdapter to create DataSet
OleDbDataAdapter SeminarDataAdapter = new OleDbDataAdapter("select *
from SeminarList",myConnection);
/// the following is for creating automatic command builder
OleDbCommandBuilder SeminarCmdBuilder = new
OleDbCommandBuilder(SeminarDataAdapter);
DataSet SeminarDataSet = new DataSet();
///fill the dataset
SeminarDataAdapter.Fill(SeminarDataSet, "SeminarList");
///set the dataset as a datasource for windows datagrid
datagrid1.DataSource = SeminarDataSet.Tables["SeminarList"].DefaultView;
datagrid1.DataBind();
}
void btnSave_Click(object sender, System.EventArgs e)
{
try
{
///the following statement
///inserts
///updates
///deletes for you
/// Without the CommandBuilder, this line would fail.
SeminarDataAdapter.UpdateCommand =
SeminarCmdBuilder.GetUpdateCommand();
SeminarDataAdapter.Update(SeminarDataSet);
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}
</script>
--
_______________________________________________
DC
"You can not reason a man out of a position he did not reach through reason"
"Don't use a big word where a diminutive one will suffice."
"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law