C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




error while inserting data continously in asp.net page


Posted Date: 20 Jun 2008      Total Responses: 4

Posted By: G.Hemadribabu       Member Level: Gold     Points: 1



hi all

i had written a query for inserting data, and it is working accordingly ,
when i start loading the data and press of insert it is working , and if i start inserting other record continoulsy it is trowing me error

i have to insert one record stop the application , and again start the application to start inserting new record,

This is my problme

The error i am getting while inserting 2nd record continoulsy is

Error : Syntax error in INSERTINTO Statement

the query i written is

Dim str As String = "insert into DPR values ('" & dd_tt.Text & "','" & ownhir.Text & "','" & own_id.Text & "','" & hir_id.Text & "','" & cat.Text & "','" & vehno.Text & "','" & site.Text & "','" & purpose.Text & "'," & iread.Text & ",'" & ireadunit.Text & "'," & funit.Text & "," & reading.Text & "," & fuel.Text & ",'" & fueltype.Text & "'," & fuelcost.Text & "," & fuelamt.Text & "," & montarget.Text & ",'" & monunit.Text & "','" & monthh.Text & "','" & yr.Text & "'," & dailyprod.Text & "," & cumm.Text & ",'" & status.Text & "','" & bdam.Text & "','" & bdpm.Text & "','" & bdreason.Text & "')"
cmd = New OleDbCommand(str, con)
cmd.ExecuteNonQuery()






Responses

Author: Subodh kumar Prajapati    20 Jun 2008Member Level: GoldRating:     Points: 2

Hi,
Try this after execution of your command. as:

cmd.ExecuteNonQuery()
con.Close()

It's will be working fine.



Author: MANIKANDAN    20 Jun 2008Member Level: SilverRating:     Points: 2

properly open and close the connection


Author: G.Hemadribabu    20 Jun 2008Member Level: GoldRating:     Points: 2

Dim str As String = "insert into DPR values ('" & dd_tt.Text & "','" & ownhir.Text & "','" & own_id.Text & "','" & hir_id.Text & "','" & cat.Text & "','" & vehno.Text & "','" & site.Text & "','" & purpose.Text & "'," & iread.Text & ",'" & ireadunit.Text & "'," & funit.Text & "," & reading.Text & "," & fuel.Text & ",'" & fueltype.Text & "'," & fuelcost.Text & "," & fuelamt.Text & "," & montarget.Text & ",'" & monunit.Text & "','" & monthh.Text & "','" & yr.Text & "'," & dailyprod.Text & "," & cumm.Text & ",'" & status.Text & "','" & bdam.Text & "','" & bdpm.Text & "','" & bdreason.Text & "')"
cmd = New OleDbCommand(str, con)
cmd.ExecuteNonQuery()
con.close()
.
Even ihad changed this option also after gettingsuggestion from our friend
but again it is trowingme error same error SYntax error in INSERT INTO





Author: G.Hemadribabu    20 Jun 2008Member Level: GoldRating:     Points: 2

Dim str As String = "insert into DPR values ('" & dd_tt.Text & "','" & ownhir.Text & "','" & own_id.Text & "','" & hir_id.Text & "','" & cat.Text & "','" & vehno.Text & "','" & site.Text & "','" & purpose.Text & "'," & iread.Text & ",'" & ireadunit.Text & "'," & funit.Text & "," & reading.Text & "," & fuel.Text & ",'" & fueltype.Text & "'," & fuelcost.Text & "," & fuelamt.Text & "," & montarget.Text & ",'" & monunit.Text & "','" & monthh.Text & "','" & yr.Text & "'," & dailyprod.Text & "," & cumm.Text & ",'" & status.Text & "','" & bdam.Text & "','" & bdpm.Text & "','" & bdreason.Text & "')"
cmd = New OleDbCommand(str, con)
cmd.ExecuteNonQuery()
con.close()
.
Even ihad changed this option also after gettingsuggestion from our friend
but again it is trowingme error same error SYntax error in INSERT INTO





Post Reply
You must Sign In to post a response.
Next : problem in Tree View Control
Previous : Browser : Disable the back button of IE
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use