Here is an update query that I am trying to run: - comm = New Data.OleDb.OleDbCommand("UPDATE TESTGEN.ITMGT.ACCESS_LOG SET REQUEST_TYPE=:newRequestType, EMPLOYEE_NAME=:newEmployeeName, PERM_TEMP=:newPermTemp, COMPUTER_NAME=:newComputerName, SIMILIAR_TO=:newSimilarTo, UPDATE_REASON =:newUpdateReason, PHONE_NUM=:newPhoneNumber, CONTACT_PERSON=:newContactPerson, CONTACT_NUM=:newContactNumber WHERE (RECORD_ID=" & requestId & ")", conn)
-
-
-
'http://forums.asp.net/t/1821702.aspx - currently not using .Text for each line; left this line in for possible code if needed
-
-
comm.Parameters.Add("RECORD_ID", OleDb.OleDbType.SmallInt)
-
comm.Parameters("RECORD_ID").Value = requestId
-
-
comm.Parameters.Add(":REQUEST_TYPE", OleDb.OleDbType.Char)
-
comm.Parameters(":REQUEST_TYPE").Value = newRequestType
-
-
comm.Parameters.Add(":EMPLOYEE_NAME", OleDb.OleDbType.VarChar)
-
comm.Parameters(":EMPLOYEE_NAME").Value = newEmployeeName
-
-
comm.Parameters.Add(":PERM_TEMP", OleDb.OleDbType.Char)
-
comm.Parameters(":PERM_TEMP").Value = newPermTemp
-
-
comm.Parameters.Add(":COMPUTER_NAME", OleDb.OleDbType.VarChar)
-
comm.Parameters(":COMPUTER_NAME").Value = newComputerName
-
-
comm.Parameters.Add(":SIMILIAR_TO", OleDb.OleDbType.VarChar)
-
comm.Parameters(":SIMILIAR_TO").Value = newSimilarTo
-
-
comm.Parameters.Add(":UPDATE_REASON", OleDb.OleDbType.VarChar)
-
comm.Parameters(":UPDATE_REASON").Value = newUpdateReason
-
-
comm.Parameters.Add(":PHONE_NUM", OleDb.OleDbType.VarChar)
-
comm.Parameters(":PHONE_NUM").Value = newPhoneNumber
-
-
comm.Parameters.Add(":CONTACT_PERSON", OleDb.OleDbType.VarChar)
-
comm.Parameters(":CONTACT_PERSON").Value = newContactPerson
-
-
comm.Parameters.Add(":CONTACT_NUM", OleDb.OleDbType.VarChar)
-
comm.Parameters(":CONTACT_NUM").Value = newContactNumber
When I run it, I receive this error:
Event Type: Information
Event Source: My Application
Event Category: None
Event ID: 0
Date: 10/8/2013
Time: 8:36:49 AM
User: N/A
Computer: CVCMS116
Description:
Index #0
Message: [DB2/NT64] SQL0313N The number of variables in the EXECUTE statement, the number of variables in the OPEN statement, or the number of arguments in an OPEN statement for a parameterized cursor is not equal to the number of values required. SQLSTATE=07004
NativeError: -313
Source: IBM OLE DB Provider for DB2
SQLState: 07001
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Any ideas on what I am doing wrong?
3 1862
You added 10 parameters but your query only has 9. Also, your parameter names are different in your query.
I have updated the code as follows. Do you know how I should write it. I have added the control that I am trying to update after this? -
Dim requestId As Integer = requestDetails.DataKey.Value
-
-
-
Dim newRequestTypeTextBox As TextBox = requestDetails.FindControl("editRequestTypeTextBox")
-
Dim newEmployeeNameTextBox As TextBox = requestDetails.FindControl("editEmployeeNameTextBox")
-
Dim newPermTempTextBox As TextBox = requestDetails.FindControl("editPermTempTextBox")
-
Dim newComputerNameTextBox As TextBox = requestDetails.FindControl("editComputerNameTextBox")
-
Dim newSimilarToTextBox As TextBox = requestDetails.FindControl("editSimilarToTextBox")
-
Dim newUpdateReasonTextBox As TextBox = requestDetails.FindControl("editUpdateReasonTextBox")
-
Dim newPhoneNumberTextBox As TextBox = requestDetails.FindControl("editPhoneNumberTextBox")
-
Dim newContactPersonTextBox As TextBox = requestDetails.FindControl("editContactPersonTextBox")
-
Dim newContactNumberBox As TextBox = requestDetails.FindControl("editContactNumberTextBox")
-
-
Dim newRequestType As String = newRequestTypeTextBox.Text
-
Dim newEmployeeName As String = newEmployeeNameTextBox.Text
-
Dim newPermTemp As String = newPermTempTextBox.Text
-
Dim newComputerName As String = newComputerNameTextBox.Text
-
Dim newSimilarTo As String = newSimilarToTextBox.Text
-
Dim newUpdateReason As String = newUpdateReasonTextBox.Text
-
Dim newPhoneNumber As String = newPhoneNumberTextBox.Text
-
Dim newContactPerson As String = newContactPersonTextBox.Text
-
Dim newContactNumber As String = newContactNumberBox.Text
-
-
-
-
Dim conn = New Data.OleDb.OleDbConnection
-
Dim comm As Data.OleDb.OleDbCommand
-
-
conn = New Data.OleDb.OleDbConnection(Session("connectionString"))
-
-
comm = New Data.OleDb.OleDbCommand("UPDATE TESTGEN.ITMGT.ACCESS_LOG SET REQUEST_TYPE=:NewRequestType, EMPLOYEE_NAME=:NewEmployeeName, PERM_TEMP=:NewPermTemp, COMPUTER_NAME=:NewComputerName, SIMILIAR_TO=:NewSimilarTo, UPDATE_REASON =:NewUpdateReason, PHONE_NUM=:NewPhoneNumber, CONTACT_PERSON=:NewContactPerson, CONTACT_NUM=:NewContactNumber WHERE (RECORD_ID=:RECORD_ID)", conn)
-
-
-
'http://forums.asp.net/t/1821702.aspx - currently not using .Text for each line; left this line in for possible code if needed
-
-
comm.Parameters.Add(":RECORD_ID", OleDb.OleDbType.SmallInt)
-
comm.Parameters(":RECORD_ID").Value = requestId
-
-
comm.Parameters.Add(":NewRequestType", OleDb.OleDbType.Char)
-
comm.Parameters(":NewRequestType").Value = newRequestType
-
-
comm.Parameters.Add(":NewEmployeeName", OleDb.OleDbType.VarChar)
-
comm.Parameters(":NewEmployeeName").Value = newEmployeeName
-
-
comm.Parameters.Add(":NewPermTemp", OleDb.OleDbType.Char)
-
comm.Parameters(":NewPermTemp").Value = newPermTemp
-
-
comm.Parameters.Add(":NewComputerName", OleDb.OleDbType.VarChar)
-
comm.Parameters(":NewComputerName").Value = newComputerName
-
-
comm.Parameters.Add(":NewSimilarTo", OleDb.OleDbType.VarChar)
-
comm.Parameters(":NewSimilarTo").Value = newSimilarTo
-
-
comm.Parameters.Add(":NewUpdateReason", OleDb.OleDbType.VarChar)
-
comm.Parameters(":NewUpdateReason").Value = newUpdateReason
-
-
comm.Parameters.Add(":NewPhoneNumber", OleDb.OleDbType.VarChar)
-
comm.Parameters(":NewPhoneNumber").Value = newPhoneNumber
-
-
comm.Parameters.Add(":NewContactPerson", OleDb.OleDbType.VarChar)
-
comm.Parameters(":NewContactPerson").Value = newContactPerson
-
-
comm.Parameters.Add(":NewContactNumber", OleDb.OleDbType.VarChar)
-
comm.Parameters(":NewContactNumber").Value = newContactNumber
-
-
-
Try
-
conn.Open()
-
comm.ExecuteNonQuery()
-
-
Catch er As OleDbException
-
Dim errorMessages As String = ""
-
Dim i As Integer
-
-
For i = 0 To er.Errors.Count - 1
-
errorMessages += "Index #" & i.ToString() & ControlChars.Cr _
-
& "Message: " & er.Errors(i).Message & ControlChars.Cr _
-
& "NativeError: " & er.Errors(i).NativeError & ControlChars.Cr _
-
& "Source: " & er.Errors(i).Source & ControlChars.Cr _
-
& "SQLState: " & er.Errors(i).SQLState & ControlChars.Cr _
-
& "Error Code: " & er.ErrorCode & ControlChars.Cr _
-
& "Type: " & er.Errors(i).GetType.ToString
-
-
-
-
-
Next i
-
-
Dim log As System.Diagnostics.EventLog = New System.Diagnostics.EventLog()
-
log.Source = "My Application"
-
log.WriteEntry(errorMessages)
-
Console.WriteLine("An exception occurred. Please contact your system administrator.")
-
-
Finally
-
conn.Close()
-
End Try
-
-
requestDetails.ChangeMode(DetailsViewMode.ReadOnly)
-
BindGrid()
-
BindDetails()
-
.aspx code:
And are you saying that the updated code is not working? You have to tell us what the error code and text is.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Randy Harris |
last post by:
I imported records into a table, later found out that many of them had
trailing spaces in one of the fields. If I'd caught it sooner, I could have
trimmed the spaces before the import.
This...
|
by: deko |
last post by:
I'm trying to update the address record of an existing record in my mdb with
values from another existing record in the same table. In pseudo code it
might look like this:
UPDATE tblAddress SET...
|
by: John |
last post by:
Hi
We have this strange problem on an access 97 app over a network. The backend
db is on a win2003 server and each pc has the front rend linking to the back
end. The app runs an update query...
|
by: Riley DeWiley |
last post by:
I have an UPDATE query that is always setting 0 records. When I cut and
paste the SQL into Access and use it, it fails in the same way unless I
coerce the date fields to be '=now()', in which case...
|
by: gnortenjones |
last post by:
I have a linked table (to an oracle db), and I am trying to run a simple update query against it to change some data, but I am getting the following error:
"...didn't update 0 fields due to a type...
|
by: abhilashcashok |
last post by:
hi guys, my prblem is that I cannot update sql query against MS ACCESS
using C#. Everytime wen i do so, i got an exception (at runtime) as
'UPDATE syntax not correct'. I don find any error in my...
|
by: Matt |
last post by:
So as you all know the great thing about ADO.NET is that I can take an
entire table from a database and dump it into an in memory datatable
using ADO.NET.
Well my question is that now that I...
|
by: zachster17 |
last post by:
Hello everyone,
I'm having difficult getting an update query to work. What I'm doing is search a table with filenames against another table that has filename wildcards that search against the...
|
by: dougmeece |
last post by:
Hello experts,
I have an update query that I want to modify records meeting a certain criteria in a table based on information on a form.
I am having trouble recognizing the table for a...
|
by: hapnendad |
last post by:
In the question statement below Field names are in and variables are in (). All fields referenced are in what I have named the ‘PAR’ Table.
Using MS Access 2003, I am working on a project...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
| |