a question about relational database with c# ? [modified]
-
hi all, i have two tables (table1 and table2). table1 contains table2's fields and a few extra fields. example: table1(x,y,z,t) in this table: x & y are text fields. table2(x,y) > in this table: x & y are date/time fields. my question is: i want to search for some data in database according to the field types in table2 but i want to get values from table1. to make it crystal clear: lets say x is startdate and y is enddate. i can compare date values in table2. but in table1 x & y values are just text fields. lets consider one example: 6/6/2006 6/16/2006. if you compare these two values as date: second one is bigger. (returns 1) but if you compare these two values as text. first one is bigger! so my problem is: i want to compare date values and get z,t from table1 according to search comparision results. finally set the result to a dataset ? thanks in advance, bye. -- modified at 6:52 Thursday 8th June, 2006
-
hi all, i have two tables (table1 and table2). table1 contains table2's fields and a few extra fields. example: table1(x,y,z,t) in this table: x & y are text fields. table2(x,y) > in this table: x & y are date/time fields. my question is: i want to search for some data in database according to the field types in table2 but i want to get values from table1. to make it crystal clear: lets say x is startdate and y is enddate. i can compare date values in table2. but in table1 x & y values are just text fields. lets consider one example: 6/6/2006 6/16/2006. if you compare these two values as date: second one is bigger. (returns 1) but if you compare these two values as text. first one is bigger! so my problem is: i want to compare date values and get z,t from table1 according to search comparision results. finally set the result to a dataset ? thanks in advance, bye. -- modified at 6:52 Thursday 8th June, 2006
Just use cast(x as datetime) or the convert function with similar syntax and it'll magically convert to a datetime value. That is, if it's properly formatted, although you seem to believe that it is.
-
hi all, i have two tables (table1 and table2). table1 contains table2's fields and a few extra fields. example: table1(x,y,z,t) in this table: x & y are text fields. table2(x,y) > in this table: x & y are date/time fields. my question is: i want to search for some data in database according to the field types in table2 but i want to get values from table1. to make it crystal clear: lets say x is startdate and y is enddate. i can compare date values in table2. but in table1 x & y values are just text fields. lets consider one example: 6/6/2006 6/16/2006. if you compare these two values as date: second one is bigger. (returns 1) but if you compare these two values as text. first one is bigger! so my problem is: i want to compare date values and get z,t from table1 according to search comparision results. finally set the result to a dataset ? thanks in advance, bye. -- modified at 6:52 Thursday 8th June, 2006
I admire ur effort in tryin to make ppl understand ur problem. However, it is a bit confusing to understand still. In relational databases and even in the one u mentioned either table1 or table2 has x and y as foreign keys. Wht I dont understand is r u having trouble with comparing or retrieving. To compare dates you can use DateTime.Compare and to retrieve values u need command and data reader. for instance, u write cmd = new OleDbcommand("Select z,t from Table1 where result ='"+ variable_with_compare_result+"'"",Conn); result can be a variable at runtime or another column in the database that stores the comparision result. I could help but i dont understand the prob If only they could see what I see in my mind