From: Diego on
that wrong with this code?

namespace Consulta_Rodeos

{

public partial class cereal : Form

{


public cereal()

{

InitializeComponent();

}

private void cereal_Load(object sender, EventArgs e)

{


//Creamos la cadena de conexion

string pathDir =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

string pathDB = System.IO.Path.Combine(pathDir, "ctagrom.sdf");

string connectionString = string.Empty;

connectionString = string.Format(@"DataSource={0}", pathDB);

//Creamos el objeto conexion

SqlCeConnection conn = new SqlCeConnection(connectionString);

//Creamos el objeto DataAdatper

SqlCeDataAdapter adapter = new SqlCeDataAdapter("SELECT * FROM Ref_Cereal
ORDER BY DESCRIP", conn);

//Creamos el objeto DataSet

DataSet ds = new DataSet("ds");

//Poblamos el objeto DataSet usando el adaptador

try

{

adapter.Fill(ds, "Ref_Cereal");

//Enlazamos los datos del dataSet a un objeto

listBox1.DataSource = ds.Tables["Ref_Cereal"];

listBox1.DisplayMember = "descrip";

listBox1.ValueMember = "cod_cereal";


adapter = null;

}

catch (SqlCeException __ERR)

{

MessageBox.Show(__ERR.Message.ToString());

}

}

Thanks!!

--
Diego


From: Ginny Caughey MVP on
Diego,

Do you get any error message?

Ginny Caughey
Device Application Development MVP

"Diego" <diegosatch(a)yahoo.com.ar> wrote in message
news:eWQQDCL0IHA.1236(a)TK2MSFTNGP02.phx.gbl...
> that wrong with this code?
>
> namespace Consulta_Rodeos
>
> {
>
> public partial class cereal : Form
>
> {
>
>
> public cereal()
>
> {
>
> InitializeComponent();
>
> }
>
> private void cereal_Load(object sender, EventArgs e)
>
> {
>
>
> //Creamos la cadena de conexion
>
> string pathDir =
> System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
>
> string pathDB = System.IO.Path.Combine(pathDir, "ctagrom.sdf");
>
> string connectionString = string.Empty;
>
> connectionString = string.Format(@"DataSource={0}", pathDB);
>
> //Creamos el objeto conexion
>
> SqlCeConnection conn = new SqlCeConnection(connectionString);
>
> //Creamos el objeto DataAdatper
>
> SqlCeDataAdapter adapter = new SqlCeDataAdapter("SELECT * FROM Ref_Cereal
> ORDER BY DESCRIP", conn);
>
> //Creamos el objeto DataSet
>
> DataSet ds = new DataSet("ds");
>
> //Poblamos el objeto DataSet usando el adaptador
>
> try
>
> {
>
> adapter.Fill(ds, "Ref_Cereal");
>
> //Enlazamos los datos del dataSet a un objeto
>
> listBox1.DataSource = ds.Tables["Ref_Cereal"];
>
> listBox1.DisplayMember = "descrip";
>
> listBox1.ValueMember = "cod_cereal";
>
>
> adapter = null;
>
> }
>
> catch (SqlCeException __ERR)
>
> {
>
> MessageBox.Show(__ERR.Message.ToString());
>
> }
>
> }
>
> Thanks!!
>
> --
> Diego
>

From: Diego on
Always catch an error and in his windows show the name of de
table..[Ref_Cereal]

Thanks


From: Ginny Caughey MVP on
Deigo,

Is there an InnerException? Are you sure the table exists?

Ginny Caughey
Device Application Development MVP

"Diego" <diegosatch(a)yahoo.com.ar> wrote in message
news:uN$HTOL0IHA.3496(a)TK2MSFTNGP03.phx.gbl...
> Always catch an error and in his windows show the name of de
> table..[Ref_Cereal]
>
> Thanks
>

From: Diego on
The table in the database exist.

If omit try and catch, VS showed the error in the line:

adapter.Fill(ds, "Ref_cereal"); señalando a "Ref_Cereal" aqnd saying that SqlCeException is not controled, attach image of screen

and in Results:
Excepción del tipo 'System.Data.SqlServerCe.SqlCeException' en System.Data.SqlServerCe.dll



Thanks.



Diego