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. solve this error

solve this error

Scheduled Pinned Locked Moved C#
help
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.
  • S Offline
    S Offline
    salil_k_singh
    wrote on last edited by
    #1

    sir i want to insert data in two tables using transaction. thee is error occurs at run time . i am giving u a my code please correct it as soon as possible: con = new OleDbConnection("provider=Microsoft.Jet.Oledb.4.0;data source=E:\\db1.mdb"); com1 = new OleDbCommand("insert into info(user_id,password,name,role,email,contact,address,designation,ques,ans) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + comboBox1.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')"); com2 = new OleDbCommand("insert into login(user_id,password,role) values('" + textBox1.Text + "','" + textBox2.Text + "','" + comboBox1.Text + "')"); com1.Connection = con; com2.Connection = con; con.Open(); tr = con.BeginTransaction(); com1.Transaction = tr; com2.Transaction = tr; com1.ExecuteNonQuery(); com2.ExecuteNonQuery(); tr.Commit(); MessageBox.Show("inserted");

    Signature preview salil_k_singh

    A S 2 Replies Last reply
    0
    • S salil_k_singh

      sir i want to insert data in two tables using transaction. thee is error occurs at run time . i am giving u a my code please correct it as soon as possible: con = new OleDbConnection("provider=Microsoft.Jet.Oledb.4.0;data source=E:\\db1.mdb"); com1 = new OleDbCommand("insert into info(user_id,password,name,role,email,contact,address,designation,ques,ans) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + comboBox1.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')"); com2 = new OleDbCommand("insert into login(user_id,password,role) values('" + textBox1.Text + "','" + textBox2.Text + "','" + comboBox1.Text + "')"); com1.Connection = con; com2.Connection = con; con.Open(); tr = con.BeginTransaction(); com1.Transaction = tr; com2.Transaction = tr; com1.ExecuteNonQuery(); com2.ExecuteNonQuery(); tr.Commit(); MessageBox.Show("inserted");

      Signature preview salil_k_singh

      A Offline
      A Offline
      Anthony Mushrow
      wrote on last edited by
      #2

      Could you tell what the error is? I'm sure it would help.

      My current favourite word is: Bacon!

      -SK Genius

      Game Programming articles start -here[^]-

      1 Reply Last reply
      0
      • S salil_k_singh

        sir i want to insert data in two tables using transaction. thee is error occurs at run time . i am giving u a my code please correct it as soon as possible: con = new OleDbConnection("provider=Microsoft.Jet.Oledb.4.0;data source=E:\\db1.mdb"); com1 = new OleDbCommand("insert into info(user_id,password,name,role,email,contact,address,designation,ques,ans) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + comboBox1.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')"); com2 = new OleDbCommand("insert into login(user_id,password,role) values('" + textBox1.Text + "','" + textBox2.Text + "','" + comboBox1.Text + "')"); com1.Connection = con; com2.Connection = con; con.Open(); tr = con.BeginTransaction(); com1.Transaction = tr; com2.Transaction = tr; com1.ExecuteNonQuery(); com2.ExecuteNonQuery(); tr.Commit(); MessageBox.Show("inserted");

        Signature preview salil_k_singh

        S Offline
        S Offline
        ScottM1
        wrote on last edited by
        #3

        Post the error and what you are trying and then we will be able to help you. You should google "SQL Injection" too as your code is vulnerable to attack, you should use parameters in your query.

        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