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. Visual Studio
  4. Database insertion errors

Database insertion errors

Scheduled Pinned Locked Moved Visual Studio
databasebusinesssaleshelpquestion
4 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.
  • J Offline
    J Offline
    John Kh
    wrote on last edited by
    #1

    Hello everyone , I am trying to insert values in one table of the database getting the values from TextBoxes and ComboBoxes . Yet it is allways giving me an overflow error no matter what I tried . This is the sode i used , I used many does this is 2 examples of what I did but none worked: First trial: Dim a As New Int32 a = TextBox1.Text Dim b As New Int32 b = ComboBox1.Text Dim c As New Int32 c = TextBox5.Text Dim d As String d = TextBox6.Text Dim ed As New Int32 ed = TextBox7.Text Dim f As New Int32 f = TextBox8.Text Dim r As New Int32 r = 0 Dim s As New Int32 s = 0 Dim t As New Int32 t = 0 cmd.CommandText = "insert into CA values(" & a & "," & b & "," & c & ",'Personal'," & r & "," & s & "," & t & ",'" & d & "'," & ed & "," & f & ")" cmd.Connection = cn cmd.ExecuteNonQuery() Trial 2 : cmd.CommandText = "insert into CA(accno,custid,balamt,acctype) values(" & TextBox1.Text & "," & ComboBox1.SelectedItem & "," & TextBox5.Text & ",'" & RadioButton1.Text & "')" cmd.Connection = cn cmd.ExecuteNonQuery() I also tried to replace a, b, c... with " & textebox1.text & " But nothing worked . The database got CA table with 10 fileds in it wich i am trying to inser the values . Anyone got a clue ? CA tabel has : Name: CA Primary Key: accno Column Name Data Type Description Accno numeric Account Number Custid numeric Customer ID Balamt Money Balance Amount Acctype char Account Type custidofjoint1 Numeric Customer ID of Joint Account Holders Custidofjoint2 Numeric Customer ID of Joint Account Holders Custidofjoint3 Numeric Customer ID of Joint Account Holders Busaddr varchar Business address of the customer overdr money Overdraft Amount ovdrlmt money Overdraft Limit John ,

    C P 2 Replies Last reply
    0
    • J John Kh

      Hello everyone , I am trying to insert values in one table of the database getting the values from TextBoxes and ComboBoxes . Yet it is allways giving me an overflow error no matter what I tried . This is the sode i used , I used many does this is 2 examples of what I did but none worked: First trial: Dim a As New Int32 a = TextBox1.Text Dim b As New Int32 b = ComboBox1.Text Dim c As New Int32 c = TextBox5.Text Dim d As String d = TextBox6.Text Dim ed As New Int32 ed = TextBox7.Text Dim f As New Int32 f = TextBox8.Text Dim r As New Int32 r = 0 Dim s As New Int32 s = 0 Dim t As New Int32 t = 0 cmd.CommandText = "insert into CA values(" & a & "," & b & "," & c & ",'Personal'," & r & "," & s & "," & t & ",'" & d & "'," & ed & "," & f & ")" cmd.Connection = cn cmd.ExecuteNonQuery() Trial 2 : cmd.CommandText = "insert into CA(accno,custid,balamt,acctype) values(" & TextBox1.Text & "," & ComboBox1.SelectedItem & "," & TextBox5.Text & ",'" & RadioButton1.Text & "')" cmd.Connection = cn cmd.ExecuteNonQuery() I also tried to replace a, b, c... with " & textebox1.text & " But nothing worked . The database got CA table with 10 fileds in it wich i am trying to inser the values . Anyone got a clue ? CA tabel has : Name: CA Primary Key: accno Column Name Data Type Description Accno numeric Account Number Custid numeric Customer ID Balamt Money Balance Amount Acctype char Account Type custidofjoint1 Numeric Customer ID of Joint Account Holders Custidofjoint2 Numeric Customer ID of Joint Account Holders Custidofjoint3 Numeric Customer ID of Joint Account Holders Busaddr varchar Business address of the customer overdr money Overdraft Amount ovdrlmt money Overdraft Limit John ,

      C Offline
      C Offline
      ChandraRam
      wrote on last edited by
      #2

      Text fields should be enclosed in "'" (single quotes). For overflow errors, check that the values entered in the text boxes do not exceed the limit of an Int32 type variable. However, you might want to read up on SQL Injection articles to see why you should not use this method to insert data into your database.

      J 1 Reply Last reply
      0
      • C ChandraRam

        Text fields should be enclosed in "'" (single quotes). For overflow errors, check that the values entered in the text boxes do not exceed the limit of an Int32 type variable. However, you might want to read up on SQL Injection articles to see why you should not use this method to insert data into your database.

        J Offline
        J Offline
        John Kh
        wrote on last edited by
        #3

        Hello everyone , How come I still get an overflow error , yet the inpu entries are still being inserted into the database ?! I just get the exception & when I check the database all seems fine . All inputs r in their places and inserted correctly !! I converted into long and other types . I tried the CLNG , VAL ... But still overflow but the diffrence is that the values r inserted into the database . Weird , No ? J ,

        1 Reply Last reply
        0
        • J John Kh

          Hello everyone , I am trying to insert values in one table of the database getting the values from TextBoxes and ComboBoxes . Yet it is allways giving me an overflow error no matter what I tried . This is the sode i used , I used many does this is 2 examples of what I did but none worked: First trial: Dim a As New Int32 a = TextBox1.Text Dim b As New Int32 b = ComboBox1.Text Dim c As New Int32 c = TextBox5.Text Dim d As String d = TextBox6.Text Dim ed As New Int32 ed = TextBox7.Text Dim f As New Int32 f = TextBox8.Text Dim r As New Int32 r = 0 Dim s As New Int32 s = 0 Dim t As New Int32 t = 0 cmd.CommandText = "insert into CA values(" & a & "," & b & "," & c & ",'Personal'," & r & "," & s & "," & t & ",'" & d & "'," & ed & "," & f & ")" cmd.Connection = cn cmd.ExecuteNonQuery() Trial 2 : cmd.CommandText = "insert into CA(accno,custid,balamt,acctype) values(" & TextBox1.Text & "," & ComboBox1.SelectedItem & "," & TextBox5.Text & ",'" & RadioButton1.Text & "')" cmd.Connection = cn cmd.ExecuteNonQuery() I also tried to replace a, b, c... with " & textebox1.text & " But nothing worked . The database got CA table with 10 fileds in it wich i am trying to inser the values . Anyone got a clue ? CA tabel has : Name: CA Primary Key: accno Column Name Data Type Description Accno numeric Account Number Custid numeric Customer ID Balamt Money Balance Amount Acctype char Account Type custidofjoint1 Numeric Customer ID of Joint Account Holders Custidofjoint2 Numeric Customer ID of Joint Account Holders Custidofjoint3 Numeric Customer ID of Joint Account Holders Busaddr varchar Business address of the customer overdr money Overdraft Amount ovdrlmt money Overdraft Limit John ,

          P Offline
          P Offline
          Purushottam2
          wrote on last edited by
          #4

          hi, first up all check the size of u r fields and then insert the data in that range.dont insert any record out off that limit. Try insert syntax as: insert into "insert into CA values('"+textbox1.text+"',...............................) ; bye bye

          purushottam

          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