View Single Post
Join Date: Jun 2008
Posts: 38
Reputation: preethi_ga is an unknown quantity at this point 
Solved Threads: 0
preethi_ga preethi_ga is offline Offline
Light Poster

Insert,delete,Update codings in VB.NET?

 
0
  #1
Jun 9th, 2008
Hello,
In .NET im using the backend as SQL Server. but when i write codings for all insert,update and delete in .NET and run the form, the error it shows like
"Oledb exception was unhandled by the user" and error in SQL query.
the codings are....follows..
  1. imports system
  2. imports system.data
  3. imports system.data.sqlclient
  4. imports dataset1.
  5.  
  6. And in Page_Load..
  7. dim con as sqlconnection
  8. dim cmd as sqlcommand
  9. dim adp as sqladapter
  10. dim data as dataset1
  11. con.connectionstring="Provider=SQLOLEDB;initialcatalog=preethi;database=ACER;integrated security=true"
  12. cmd.connection=con
  13. cmd=new sqlcommand("select * from emp"),con
  14. adp=new sqldataadapter(cmd)
  15. adp.Fill(data)
  16.  
  17. 'since i have only 3 fields
  18. textbox1.text=data.tables(1).rows(0).item(0)
  19. textbox2.text=data.tables(1).rows(0).item(1)
  20. textbox3.text=data.tables(1).rows(0).item(2)
  21.  
  22. In Insert button-click event.....
  23. ' its bcoz the second textbox has numeric value and 1st and 3rd have only string values.
  24.  
  25. cmd = new sqlcommand("insert into emp values( ' " & textbox1.text & " ', " & textbox2.text & ", ' " & textbox3.text & " ')" , con
  26. cmd.executeNonQuery()
  27. Response.write(" One record inserted").
So these are the codings im using. for delete also the same typeim using. but im getting error, can anyone help me to solve this?
Last edited by Ancient Dragon; Jan 13th, 2009 at 10:59 am. Reason: add code tags
Reply With Quote