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. inserting datagridview rows in database(windows application)

inserting datagridview rows in database(windows application)

Scheduled Pinned Locked Moved C#
helpcsharpdatabase
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.
  • A Offline
    A Offline
    avvaru murali
    wrote on last edited by
    #1

    Hi, iam doing windows application with c#.. i have to insert datagridview rows into database... with my code data is inserting into database and at the same time it is giving error ("unhandled datatype mismatch") i check with all my database datatypes and text what iam typing. so please provide some help.. mycode is string connection = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data source= D:\inventory\management\management\database\muralicell.mdb"; OleDbConnection myconnection = new OleDbConnection(connection); myconnection.Open(); for (int i = 0; i < inwardgrid.Rows.Count; i++) { string insproducts = "INSERT INTO product_details(productid,Invoice_number,productname,units,received_date)VALUES('" + inwardgrid.Rows[i].Cells[0].Value + "','" + inwardinvno.Text + "','" + inwardgrid.Rows[i].Cells[1].Value + "','" + inwardgrid.Rows[i].Cells[2].Value + "','" + inwardrecdate.Text + "')"; OleDbCommand insprocommand = new OleDbCommand(insproducts, myconnection); insprocommand.ExecuteNonQuery(); insprocommand.Dispose(); } myconnection.Close();

    murali krishna

    U 1 Reply Last reply
    0
    • A avvaru murali

      Hi, iam doing windows application with c#.. i have to insert datagridview rows into database... with my code data is inserting into database and at the same time it is giving error ("unhandled datatype mismatch") i check with all my database datatypes and text what iam typing. so please provide some help.. mycode is string connection = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data source= D:\inventory\management\management\database\muralicell.mdb"; OleDbConnection myconnection = new OleDbConnection(connection); myconnection.Open(); for (int i = 0; i < inwardgrid.Rows.Count; i++) { string insproducts = "INSERT INTO product_details(productid,Invoice_number,productname,units,received_date)VALUES('" + inwardgrid.Rows[i].Cells[0].Value + "','" + inwardinvno.Text + "','" + inwardgrid.Rows[i].Cells[1].Value + "','" + inwardgrid.Rows[i].Cells[2].Value + "','" + inwardrecdate.Text + "')"; OleDbCommand insprocommand = new OleDbCommand(insproducts, myconnection); insprocommand.ExecuteNonQuery(); insprocommand.Dispose(); } myconnection.Close();

      murali krishna

      U Offline
      U Offline
      Ujjaval Modi
      wrote on last edited by
      #2

      Hi, Just try to put your code in try & catch block. Because you are getting datatype mismatch error. The conflict is between the data you are passing and the data-type of the fields in database. May be error is due to date field.

      Regards, Ujjaval Modi

      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