Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. a question about relational database with c# ? [modified]

a question about relational database with c# ? [modified]

Scheduled Pinned Locked Moved C#
questioncsharpdatabasehelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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

    S A 2 Replies Last reply
    0
    • L Lost User

      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

      S Offline
      S Offline
      Stephan Samuel
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Lost User

        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

        A Offline
        A Offline
        alyeasad
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups