473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Update Using a parametrized Query



Hi:
I have used the following code for my update query button I have used
VB.Net

Private Sub btncollections_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btncollections.Click
Const connstr As String = "Provider=sqloledb;Data Source=Athena;Initial
Catalog=OCACollections_DB;Integrated Security=SSPI;"
Dim objConn As New OleDbConnection(connstr)
Dim MYsql As String = "Insert into
tblCollectionReports(CasesAssessed,CostAssessed) Values
(@Cases,@AssessedCosts)"
Dim objcmd As New OleDbCommand(MYsql, objConn)
objcmd.CommandType = CommandType.StoredProcedure
With objcmd.Parameters
.Add(New OleDbParameter("@Cases", txtcases.Text))
.Add(New OleDbParameter("@AssessedCosts",
txtassessedcosts.Text))
End With
objcmd.Connection.Open()
objcmd.ExecuteNonQuery()
objcmd.Connection.Close()

Upon clicking I get the following error

Syntax error or access violation
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error or
access violation

Source Error:
Line 121: End With
Line 122: objcmd.Connection.Open()
Line 123: objcmd.ExecuteNonQuery()
Line 124: objcmd.Connection.Close()
Line 125: End Sub
Source File: C:\OCACollections\ProgramCollections.aspx.vb Line: 123

What is wrong with the above code please help?

Nov 19 '05 #1
1 1625
jagdishl,

The first thing to check is if the account your website is running under has
been given permission to the SQL database. If your site is running as an
anonymous user then it should be using the IUSR_[Your Machine Name Here]
account, if you are running with <identity impersonate=true> in your
web.config then you are most likely running under the ASPNET account. Make
certain the appropriate account has been given access to run the update
procedure for starters.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
<ja******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...


Hi:
I have used the following code for my update query button I have used
VB.Net

Private Sub btncollections_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btncollections.Click
Const connstr As String = "Provider=sqloledb;Data Source=Athena;Initial
Catalog=OCACollections_DB;Integrated Security=SSPI;"
Dim objConn As New OleDbConnection(connstr)
Dim MYsql As String = "Insert into
tblCollectionReports(CasesAssessed,CostAssessed) Values
(@Cases,@AssessedCosts)"
Dim objcmd As New OleDbCommand(MYsql, objConn)
objcmd.CommandType = CommandType.StoredProcedure
With objcmd.Parameters
.Add(New OleDbParameter("@Cases", txtcases.Text))
.Add(New OleDbParameter("@AssessedCosts",
txtassessedcosts.Text))
End With
objcmd.Connection.Open()
objcmd.ExecuteNonQuery()
objcmd.Connection.Close()

Upon clicking I get the following error

Syntax error or access violation
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error or
access violation

Source Error:
Line 121: End With
Line 122: objcmd.Connection.Open()
Line 123: objcmd.ExecuteNonQuery()
Line 124: objcmd.Connection.Close()
Line 125: End Sub
Source File: C:\OCACollections\ProgramCollections.aspx.vb Line: 123

What is wrong with the above code please help?

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update...
4
by: dp | last post by:
After looking and looking, it appears that Access ADPs graphic query designer won't display: update customer set = . from customer, where customer. = .; It comes up with the "Query...
5
by: Don Seckler | last post by:
I have an update query that runs when a report closes. I have several reports that will need to run the update query with diferent criteria. I'd like to simply make the criteria change in the...
8
by: rriness | last post by:
I'm getting an inconsistent failure when trying to save data in ADO.Net. I'm using an Access database with a simple query - SELECT StudentID, FirstName, LastName FROM Students - and have no...
2
by: bobabooey2k | last post by:
I have an update query with one field having in its "Update to" cell a DLookup statement. This query takes 2-3 minutes on 3000 records. Can I avoid dlookup here using multiple queries? An...
0
by: Halimaji Nijazi | last post by:
Hi everybody I've read a lot about parametrized services and now I want to test it. My problem is, how should I create a simple parametrized service? How starting this service whithin .NET? ...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
3
by: RAG2007 | last post by:
I'm using the QueryDef and Execute method to update a record in my MySQL backend. Problem: When the Passthrough update query is defined using QueryDef, it becomes a select query, and I cannot use...
3
by: xlar54 | last post by:
I am writing a parametrized query, where Im building an UPDATE statement through concatenation, and then adding the parameters such as: UPDATE myTable SET = @newcolumna, = @newcolumnb WHERE ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.