List Info

Thread: Re: aplication ado.net




Re: aplication ado.net
user name
2008-02-24 08:11:42
That's a lot of code to look at.

Show us where you're trying to select or getvalue the data.

If you're saying data is not displaying in your dataGridView items, then I suspect you're missing a call to .DataBind()


On 2/23/08, dhpacheco < denishernandezpachecogmail.com">denishernandezpachecogmail.com> wrote:

Hello
I'm doing an application using VS 2005, c# for management a DB, but I
new using the language, neither have experience in programming. Please
could someone tell me if this is correct?
I include a datase in my project and create variables tableadapter for
each table of the dataset.
Now I need operate the DB, using insertions is easy 'cause the
designer creates the storage procedures, but I need to get values of
the BD. I thought that an option was to use Dataset variables so that
alter using selects could get a copy under which to obtain datas, but
don't know how to access a method getvalue (or something like that), I
need to use storage procedures that return scalar values, I'm using
some but that return datasets, but have problems with variables.
I attach the code for recomendations. Thanks for your time.

namespace Registro
{
 &nbsp; &nbsp;public partial class Form1 : Form
 ; &nbsp; {
private HojaFirmaTableAdapter HojaFirma = new HojaFirmaTableAdapter();
private InstitucionTableAdapter Institucion = new
InstitucionTableAdapter();
private TrabajadorTableAdapter Trabajador = new
TrabajadorTableAdapter();
private SesionesTableAdapter Sesiones = new SesionesTableAdapter();

private DateTime dmahmsg;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

this.hojaFirmaTableAdapter.Fill(this.registroDataSet1.HojaFirma);
 &nbsp; &nbsp; &nbsp;   ; &nbsp; // TODO: esta línea de código carga datos en la tabla
'registroDataSet.HojaFirma&#39; Puede moverla o quitarla según sea
necesario.
registroDataSet1.EnforceConstraints = false;

dataGridView1.DataSource = HojaFirma.GetData(); // show HojaFirma
table

dataGridView2.DataSource = Institucion.GetData();//show
Institucion
 &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; //
table

}

private void button1_Click(object sender, EventArgs e)
{
string cbi = textBox1.Text; // Gets the code barr
Int64 cb = Convert.ToInt64(cbi); // converts the code to put it in
the
   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  //DB

DataTable ndt = new DataTable(); // Creates a new DataTable variable
ndt = Trabajador.GetDataBy(cb); &nbsp;// GetDataBy is a storage proc.
that
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  //returns a DataTable with the code
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  // entered if it exist in the
BD
int endt = ndt.Rows.Count; // endt returns the estate of the
DataTable
  ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; //(empty or not)

if (endt == 0)
{
MessageBox.Show(";Worker not registered in Data Base");
}
else if (endt == 1) &nbsp;// Worker registered
{
DataTable ndt1 = new DataTable(); // Creates a new DataTable variable





// Sesion de entrada 1
if (dmahmsg.TimeOfDay >= new TimeSpan(8, 30, 0) && dmahmsg.TimeOfDay
<= new TimeSpan(11, 30, 0))
{
MessageBox.Show(";Sesion de entrada 1");
}

// Sesion de entrada 2
else if (dmahmsg.TimeOfDay >= new TimeSpan(13, 30, 0) &&
dmahmsg.TimeOfDay <= new TimeSpan(17, 0, 0))
{
MessageBox.Show(";Sesion de entrada 2");
}

DateTime fecha = dmahmsg;
DateTime sesionent1 = dmahmsg;
DateTime sesionsal1 = dmahmsg;
DateTime sesionent2 = dmahmsg;
DateTime sesionsal2 = dmahmsg;
DateTime sesionextent = dmahmsg;
DateTime sesionextsal = dmahmsg;
int cod_aus = 14;
int h_ause = 5;
int ext = 2;
string obs = "denis";
int inst = 1;

HojaFirma.InsertarTrabajador(cb, fecha, sesionent1, sesionsal1,
 &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   sesionent2,sesionsal2, sesionextent,
 &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  sesionextsal,cod_aus, h_ause, ext, obs,
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp;  inst);
}
dataGridView1.DataSource = HojaFirma.GetData();
textBox1.Clear();&nbsp;  // Limpia el control para recibir otro codigo de
 &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp;// barras
}

best regards




--
--Andy Badera
http://andrew.badera.us/
andrewbadera.us">andrewbadera.us
(518) 641-1280
Google me: http://www.google.com/search?q=andrew+badera
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting&quot; group.
To post to this group, send email to DotNetDevelopmentgooglegroups.com
To unsubscribe from this group, send email to DotNetDevelopment-unsubscribegooglegroups.com
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )