« ODBC et CSharp » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
[[Category:CSharp]]
[[Category:CSharp]]
<kode lang="csharp">
<kode lang="csharp">
OdbcDataAdapter dbAdaptater = new OdbcDataAdapter("SELECT * FROM table WHERE validity_date < ?", odbcConnection);
// use an ODBC DSN name
using var odbcConnection = new OdbcConnection("DSN=MyConnection");


dbAdaptater.SelectCommand.Parameters.Add("@date", OdbcType.DateTime).Value = maxLimitDate;
var odbcDataAdapter = new OdbcDataAdapter("SELECT * FROM table WHERE validity_date < ?", odbcConnection);
odbcDataAdapter.SelectCommand.Parameters.Add("@date", OdbcType.DateTime).Value = maxLimitDate;


var dt = new DataTable();
var dataTable = new DataTable();
odbcConnection.Open();
odbcConnection.Open();
dbAdaptater.Fill(dt);
odbcDataAdapter.Fill(dataTable);
odbcConnection.Close();
</kode>
</kode>

Version du 13 mars 2023 à 15:08

Csharp.svg
// use an ODBC DSN name
using var odbcConnection = new OdbcConnection("DSN=MyConnection");

var odbcDataAdapter = new OdbcDataAdapter("SELECT * FROM table WHERE validity_date < ?", odbcConnection);
odbcDataAdapter.SelectCommand.Parameters.Add("@date", OdbcType.DateTime).Value = maxLimitDate;

var dataTable = new DataTable();
odbcConnection.Open();
odbcDataAdapter.Fill(dataTable);