G
Guest
I have the follow code:
private void crear() {
//creating a dataset
DataSet myDataset=null;
SqlConnection sqlConnection=null;
SqlDataAdapter sqlCommand=null;
try {
//create an instance for a SqlConnection and a Sql Command
sqlConnection = new SqlConnection("server=.; database=JF;
Trusted_Connection=false; uid=sa; pwd=; Pooling=true;");
sqlCommand = new SqlDataAdapter("select
cantidad,concepto,prec_unit,valor_venta from fact_detalle",sqlConnection);
myDataset = new DataSet();
//mark the command as a text
sqlCommand.SelectCommand.CommandType = CommandType.Text;
//open the connection and execute
sqlConnection.Open();
sqlCommand.Fill(myDataset);
}
catch {
throw;
}
finally {
if(sqlConnection!=null)
sqlConnection.Close();
// MessageBox.Show("The connection is close");
}
// return myDataset;
dataGrid1.DataSource=myDataset.Tables[0];
}
private void nueva_fila()
{
DataRow anyRow = myDataset.Tables[0].NewRow();
}
---------------------------------
on nueva_fila there´s an error , when compila the "myDataset" is underlined
and the follow task is shown:
The type or namespace name 'myDataset' could not be found (are you missing a
using directive or an assembly reference?)
private void crear() {
//creating a dataset
DataSet myDataset=null;
SqlConnection sqlConnection=null;
SqlDataAdapter sqlCommand=null;
try {
//create an instance for a SqlConnection and a Sql Command
sqlConnection = new SqlConnection("server=.; database=JF;
Trusted_Connection=false; uid=sa; pwd=; Pooling=true;");
sqlCommand = new SqlDataAdapter("select
cantidad,concepto,prec_unit,valor_venta from fact_detalle",sqlConnection);
myDataset = new DataSet();
//mark the command as a text
sqlCommand.SelectCommand.CommandType = CommandType.Text;
//open the connection and execute
sqlConnection.Open();
sqlCommand.Fill(myDataset);
}
catch {
throw;
}
finally {
if(sqlConnection!=null)
sqlConnection.Close();
// MessageBox.Show("The connection is close");
}
// return myDataset;
dataGrid1.DataSource=myDataset.Tables[0];
}
private void nueva_fila()
{
DataRow anyRow = myDataset.Tables[0].NewRow();
}
---------------------------------
on nueva_fila there´s an error , when compila the "myDataset" is underlined
and the follow task is shown:
The type or namespace name 'myDataset' could not be found (are you missing a
using directive or an assembly reference?)