Login Register Actian.com  

Actian Community Forum



Reply
 
LinkBack Thread Tools Display Modes
Old 2012-02-03   #1 (permalink)
Junior Member
 
Join Date: Feb 2012
Posts: 4
Default Compare date with Ingres.Client and C#

Hello. I work with Ingres.Client 2.1.0.0 in C#.

My code:

IngresConnection IngCnn = new IngresConnection("UID = recauda; PWD = xxxx; Role ID = sprtri; Role Password = xxxx;Host=172.26.31.122;Database=labprod;date_form at=DMY;Connect Timeout=60");
IngresCommand Cmd = IngCnn .CreateCommand();

IngCnn.Open();

CadSQLIngres = "select contrib_origen, contrib_destino, usuario, fecha_orden" +
" from conver_contrib";


DataSet ConverContrib = new DataSet();
IngresDataAdapter DAConCon = new IngresDataAdapter(CadSQLIngres,IngCnn);
DAConCon.Fill(ConverContrib);

TotalAConvertir = ConverContrib.Tables[0].Rows.Count;
foreach (DataRow FilaConCon in ConverContrib.Tables[0].Rows)
{

..........
..........
..........

CadSQLIngres = " update conver_contrib set fecha_conv = 'now'" +
" where contrib_origen = " + FilaConCon["contrib_origen"] +
" and contrib_destino = " + FilaConCon["contrib_destino"] +
" and fecha_orden = '" + FilaConCon["fecha_orden"].ToString() + "'";

NTuplas = Cmd.ExecuteNonQuery();
}

The result of NTuplas is 0 because fecha_orden = '" + FilaConCon["fecha_orden"].ToString() + "'" dates do not match.

If connect by ODBC (OdbcConnection) to Ingres, the update work fine.

thank you very much.

En español.
Con el Ingres.Client, a la hora de hacer el update, el resultado es cero, porque las fechas no coinciden, siendo estas las mismas (mismo campo y misma tabla).

Por ODCB la sentencia se ejecuta sin nigún problema.

Muchas gracias.
Juan_Carlos is offline   Reply With Quote
Old 2012-02-03   #2 (permalink)
Ingres Community
 
Join Date: Mar 2007
Location: Medfield, Massachusetts, USA
Posts: 231
Default

Hi Juan,

What is the Ingres data type of the fecha_orden column? VARCHAR? ANSIDATE? INGRESDATE? TIMESTAMP? What is the metadata type of the FilaConCon["fecha_orden"] column in the DataTable. It would be useful to know what the data type is when .NET converts the value to a String using the default culture on the ToString() call. What is the output of the FilaConCon["fecha_orden"].ToString()? Keep in mind that the date_format=DMY is not used by the data provider but is only passed on to the DBMS server for its processing. All formating rules in ToString() are done purely by the .NET Framework using the default culture.

Hope this helps,
Dave
thoda04 is offline   Reply With Quote
Old 2012-02-04   #3 (permalink)
Junior Member
 
Join Date: Feb 2012
Posts: 4
Default

Hi and thanks

Ingres data types of table conver_contrib:
create table conver_contrib(
contrib_origen integer not null default 0,
contrib_destino integer not null default 0,
usuario varchar(7) not null default ' ',
fecha_orden date not null default ' ',
fecha_conv date not null default ' '
)

The metadata type of the FilaConCon["fecha_orden"] column is Date.
The output of the FilaConCon["fecha_orden"].ToString() is "20/01/2012 8:10:54".
I use date_format=DMY to save a date "20/01/2012" and not return error Invalid number of month.

If i use
select varchar(fecha_orden) from conver_contrib
and after
update conver_contrib set fecha_conv = 'now' where varchar(fecha_orden) = '" + FilaConCon["fecha_orden"] +"'"
This work fine
Juan_Carlos is offline   Reply With Quote
Old 2012-02-04   #4 (permalink)
Junior Member
 
Join Date: Feb 2012
Posts: 4
Default

Hi.
I discovered that the problem is in the hours and not the date
If the field contains "20/01/2012 8:20:55"
select fecha_orden from conver_contrib
update conver_contrib set fecha_conv = 'now' where fecha_orden = '" + FilaConCon["fecha_orden"].ToStrig()
Don't work
But if the field contains "20/01/2012" the Update work fine.

Thank you very much.
Juan_Carlos is offline   Reply With Quote
Old 2012-02-04   #5 (permalink)
Ingres Community
 
kschendel's Avatar
 
Join Date: Mar 2007
Location: Pittsburgh, PA
Posts: 1,661
Default

Are you sure those dates in the table are ingresdate and not ansidate? ansidate doesn't allow a time part.
kschendel is offline   Reply With Quote
Old 2012-02-06   #6 (permalink)
Junior Member
 
Join Date: Feb 2012
Posts: 4
Default

Hi.
The field is declare "fecha_orden date not null default ' '," and I can do two insert
insert into conver_contrib set fecha_orden = 'today' -- >the field contain '06.02.2012'
or
insert into conver_contrib set fecha_orden = 'now' -- >the field contain '06.02.2012 14:39:22'
Juan_Carlos is offline   Reply With Quote

Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


© 2011 Actian Corporation. All Rights Reserved