Sunday, May 8, 2011

Heather Brooke Pregnant

In C sharp, select records in an Access database (version 97) using the ODBC libraries

Here
write the ODE to select the maximum value of a particular field: private void

IdMasAlto () {

DatosConexionABaseDeDatos DatosConexionABaseDeDatos odatosConexion = new ();
odatosConexion.getConexion OleDbConnection connection = ( )
conexion.Open ();
DataSet ds = new DataSet ();
DataTable dt = new DataTable ();

string strSQL = "SELECT MAX (IdTipo) AS last Type FROM "
/ / The query returns only one record in a column: A value.
oAdaptador OleDbDataAdapter = new OleDbDataAdapter (strSQL, conn);
oAdaptador.Fill (ds, "elultimo");
dt = ds.Tables ["elultimo"];
DataRow row = dt . Rows [0];
/ / ID is a property
ID = Convert.ToInt32 (row ["last"]. ToString ());
conexion.Close ();}


This códigio, modifying it serve to go Several registry returns. Being well: if (dt.Rows.Count == 0)
this.lblUsuario.Text = "No such user
..."; else {

foreach (row in System.Data.DataRow dt.Rows) {

this.lblUsuario.Text = "Welcome" + row ["name"]. ToString ();}

}



Of course, before go, remember to do the following imports before, in opening lines:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;



Greetings;)

0 comments:

Post a Comment