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. Prolem in inserting new Row-DB2 Date Time

Prolem in inserting new Row-DB2 Date Time

Scheduled Pinned Locked Moved C#
helpquestionannouncement
2 Posts 2 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.
  • K Offline
    K Offline
    kidus1
    wrote on last edited by
    #1

    hi I got a problem in inserting new rows to a datatable.How can I insert dates in a data table using DB2. Here is some code... DB2Connection conn = new DB2Connection(connectionString); DB2DataAdapter DataAd= new DB2DataAdapter(select, conn); DataSet ds=new DataSet(); DataAd.Fill(ds, "Table Name"); Datarow dr = ds.Tables["Table Name"].NewRow(); DB2Command aCommand = new DB2Command(select, conn); aCommand.CommandType = CommandType.Text; aCommand = new DB2Command("INSERT INTO CL.VSCHTM("ST_DTE")" "VALUES ("#" + dr["ST_DTE"]+"#",conn); DataAd.InsertCommand = aCommand; DataAd.Update(ds, "Table Name"); aCommand.Parameters.Add(new DB2Parameter("ST_DTE",DB2Type.Date, 0, "ST_DTE")); aCommand.UpdatedRowSource = UpdateRowSource.OutputParameters; It doesn't add new row ,any help?? kidus

    K 1 Reply Last reply
    0
    • K kidus1

      hi I got a problem in inserting new rows to a datatable.How can I insert dates in a data table using DB2. Here is some code... DB2Connection conn = new DB2Connection(connectionString); DB2DataAdapter DataAd= new DB2DataAdapter(select, conn); DataSet ds=new DataSet(); DataAd.Fill(ds, "Table Name"); Datarow dr = ds.Tables["Table Name"].NewRow(); DB2Command aCommand = new DB2Command(select, conn); aCommand.CommandType = CommandType.Text; aCommand = new DB2Command("INSERT INTO CL.VSCHTM("ST_DTE")" "VALUES ("#" + dr["ST_DTE"]+"#",conn); DataAd.InsertCommand = aCommand; DataAd.Update(ds, "Table Name"); aCommand.Parameters.Add(new DB2Parameter("ST_DTE",DB2Type.Date, 0, "ST_DTE")); aCommand.UpdatedRowSource = UpdateRowSource.OutputParameters; It doesn't add new row ,any help?? kidus

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Is the datetime the min value in .net? There is a chance that db2 doesn't support it. I know sql server does not. I would think if the row doesn't get inserted there must be an error message. Have you tried to do the insert outside of .net to see if it works? Ben

      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