943,987 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 629
  • ASP.NET RSS
Jul 20th, 2008
0

Data inserting problem

Expand Post »
Hi ,
In the Insert button i have used the follwing coding,

asp.net Syntax (Toggle Plain Text)
  1. cmd = New OleDb.OleDbCommand("insert into emp values( ' " & TextBox1.Text & " ' , " & TextBox2.Text & "
  2.  
Textbox 1 has String and Textbox 2 has Numeric data.

asp.net Syntax (Toggle Plain Text)
  1. con.Open()
  2. cmd.ExecuteNonQuery

Connection string "con" declared Globally.
By executing the code i got error like, "OleDb Exception was UnHandled by the user code"
" Line 1: Incorrect syntax Error "


After that i changed the code,

asp Syntax (Toggle Plain Text)
  1. Dim Ssql as String = "insert into emp(nam,regno)values(@nam,@regno)"
  2. cmd = New SqlCommand(Ssql,con)
  3. Dim Op1,Op2 as SqlParameter
  4. Op1 = cmd.Parameter("@nam",SqlDbType.Char))
  5. Op2 = cmd.Parameter("@regno",SqlDbType.Char))
  6. Op1.Direction = ParameterDirection.Input
Like wise for Op2 also.
asp.net Syntax (Toggle Plain Text)
  1. Op1.Value = TextBox1.Text
  2. Op2.Value = Textbox2.Text
  3. cmd.ExecuteNonQuery

So by executing the above code, there is no error but same data's are inserted again and again, like if the textbox1 = preethi, textbox2 = 2001 are the data alredy present. then if i
clear those data by the "ADDNEW button" and if i insert new data , the new data are not stored, again that preethi and 2001 are stored.
i donno what will be the mistake..........!
Last edited by peter_budo; Jul 20th, 2008 at 11:08 am. Reason: Corecting tags, [code=asp.net]YOUR CODE HERE[/code]
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
preethi_ga is offline Offline
38 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Batch print barcode in ASP.NET, C#, on client side
Next Thread in ASP.NET Forum Timeline: store files in database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC