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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Data not insert

Data not insert

Scheduled Pinned Locked Moved C#
helpc++javadatabasesql-server
5 Posts 4 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.
  • M Offline
    M Offline
    mjawadkhatri
    wrote on last edited by
    #1

    hi, i need your help when i insert data in my table show error Error is ERROR [42S02] [Microsoft][SQL Native Client][SQL Server]Invalid object name 'test' and i use this coding string MyString = "Select * from test"; OdbcConnection cn = new OdbcConnection("Driver={SQL Native Client};Server=localhost;UID=sa;PWD=java;"); OdbcCommand cmd = new OdbcCommand(MyString, cn); cn.Open(); MessageBox.Show("Connected"); cmd.CommandText = "insert into test values ('" + textBox1.Text + "','" + textBox2.Text + "')"; MessageBox.Show(cmd.CommandText); cmd.ExecuteNonQuery(); cn.Close(); Thanks In Advance jawad khatri

    L K R 3 Replies Last reply
    0
    • M mjawadkhatri

      hi, i need your help when i insert data in my table show error Error is ERROR [42S02] [Microsoft][SQL Native Client][SQL Server]Invalid object name 'test' and i use this coding string MyString = "Select * from test"; OdbcConnection cn = new OdbcConnection("Driver={SQL Native Client};Server=localhost;UID=sa;PWD=java;"); OdbcCommand cmd = new OdbcCommand(MyString, cn); cn.Open(); MessageBox.Show("Connected"); cmd.CommandText = "insert into test values ('" + textBox1.Text + "','" + textBox2.Text + "')"; MessageBox.Show(cmd.CommandText); cmd.ExecuteNonQuery(); cn.Close(); Thanks In Advance jawad khatri

      L Offline
      L Offline
      loyal ginger
      wrote on last edited by
      #2

      Did you verify that you have a table named "test"?

      M 1 Reply Last reply
      0
      • M mjawadkhatri

        hi, i need your help when i insert data in my table show error Error is ERROR [42S02] [Microsoft][SQL Native Client][SQL Server]Invalid object name 'test' and i use this coding string MyString = "Select * from test"; OdbcConnection cn = new OdbcConnection("Driver={SQL Native Client};Server=localhost;UID=sa;PWD=java;"); OdbcCommand cmd = new OdbcCommand(MyString, cn); cn.Open(); MessageBox.Show("Connected"); cmd.CommandText = "insert into test values ('" + textBox1.Text + "','" + textBox2.Text + "')"; MessageBox.Show(cmd.CommandText); cmd.ExecuteNonQuery(); cn.Close(); Thanks In Advance jawad khatri

        K Offline
        K Offline
        kevinnicol
        wrote on last edited by
        #3

        You also didn't supply which database or catalogue you wish to connect to, so you are probably just connnected to the master database which I very much doubt has a table called test. Add a Database=[dbname]; section to your query string.

        1 Reply Last reply
        0
        • M mjawadkhatri

          hi, i need your help when i insert data in my table show error Error is ERROR [42S02] [Microsoft][SQL Native Client][SQL Server]Invalid object name 'test' and i use this coding string MyString = "Select * from test"; OdbcConnection cn = new OdbcConnection("Driver={SQL Native Client};Server=localhost;UID=sa;PWD=java;"); OdbcCommand cmd = new OdbcCommand(MyString, cn); cn.Open(); MessageBox.Show("Connected"); cmd.CommandText = "insert into test values ('" + textBox1.Text + "','" + textBox2.Text + "')"; MessageBox.Show(cmd.CommandText); cmd.ExecuteNonQuery(); cn.Close(); Thanks In Advance jawad khatri

          R Offline
          R Offline
          rockracker
          wrote on last edited by
          #4

          cmd.CommandText = "insert into test values ('" + textBox1.Text + "','" + textBox2.Text + "')"; --------------------------------------------------------------------------------------- try this one.... cmd.CommandText = "insert into test values ('" textBox1.Text + "','" + textBox2.Text + "')"; :doh: :doh: :doh: :doh: :doh: :doh: :doh:

          1 Reply Last reply
          0
          • L loyal ginger

            Did you verify that you have a table named "test"?

            M Offline
            M Offline
            mjawadkhatri
            wrote on last edited by
            #5

            yes i have test table

            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