473,586 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles btncollections. Click
Const connstr As String = "Provider=sqlol edb;Data Source=Athena;I nitial
Catalog=OCAColl ections_DB;Inte grated Security=SSPI;"
Dim objConn As New OleDbConnection (connstr)
Dim MYsql As String = "Insert into
tblCollectionRe ports(CasesAsse ssed,CostAssess ed) Values
(@Cases,@Assess edCosts)"
Dim objcmd As New OleDbCommand(MY sql, objConn)
objcmd.CommandT ype = CommandType.Sto redProcedure
With objcmd.Paramete rs
.Add(New OleDbParameter( "@Cases", txtcases.Text))
.Add(New OleDbParameter( "@AssessedCosts ",
txtassessedcost s.Text))
End With
objcmd.Connecti on.Open()
objcmd.ExecuteN onQuery()
objcmd.Connecti on.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.Ole Db.OleDbExcepti on: Syntax error or
access violation

Source Error:
Line 121: End With
Line 122: objcmd.Connecti on.Open()
Line 123: objcmd.ExecuteN onQuery()
Line 124: objcmd.Connecti on.Close()
Line 125: End Sub
Source File: C:\OCACollectio ns\ProgramColle ctions.aspx.vb Line: 123

What is wrong with the above code please help?

Nov 19 '05 #1
1 1632
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=tru e> 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******** *************@o 13g2000cwo.goog legroups.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.EventArg s) Handles btncollections. Click
Const connstr As String = "Provider=sqlol edb;Data Source=Athena;I nitial
Catalog=OCAColl ections_DB;Inte grated Security=SSPI;"
Dim objConn As New OleDbConnection (connstr)
Dim MYsql As String = "Insert into
tblCollectionRe ports(CasesAsse ssed,CostAssess ed) Values
(@Cases,@Assess edCosts)"
Dim objcmd As New OleDbCommand(MY sql, objConn)
objcmd.CommandT ype = CommandType.Sto redProcedure
With objcmd.Paramete rs
.Add(New OleDbParameter( "@Cases", txtcases.Text))
.Add(New OleDbParameter( "@AssessedCosts ",
txtassessedcost s.Text))
End With
objcmd.Connecti on.Open()
objcmd.ExecuteN onQuery()
objcmd.Connecti on.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.Ole Db.OleDbExcepti on: Syntax error or
access violation

Source Error:
Line 121: End With
Line 122: objcmd.Connecti on.Open()
Line 123: objcmd.ExecuteN onQuery()
Line 124: objcmd.Connecti on.Close()
Line 125: End Sub
Source File: C:\OCACollectio ns\ProgramColle ctions.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
3389
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 the original tblPO. However, when I introduce the setup file into the query I cannot update the result. THis is true if I make a link to Setup or not....
4
2248
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 Definitions Differ" dialog box. Anybody know anything about this? I can live this with I guess, however it was sure
5
13208
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 report vba instead of making different queries. Here's my query sql: UPDATE Draw SET Draw.Billed = Yes WHERE (((Draw.Billed)=No) AND...
8
1896
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 other users in the database. I keep getting the message 'Operation must use an updateable query.' Process seems to work on some PC's, not others. Is...
2
5058
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 underlying subquery to this Update query involves a MAX function on a date field, which is then used in the DLookup statement. Any help appreciated....
0
1017
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? Do someone has samples or sample code or any step-by-step instructions? Thanks alot
16
3482
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 renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate...
3
9114
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 the Execute Method. Instance: The following code is defined as a query called "AddCost" UPDATE tblinitiative SET tblinitiative.Estimate = " &...
3
3121
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 = @origcolumna AND = @origcolumnb This works fine, unless one of the original database values are a NULL. Im creating the parameters as:
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.