If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Updating a record

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-16-02, 11:48
clinel clinel is offline
Registered User
 
Join Date: Oct 2002
Location: Western part of Georgia, USA
Posts: 123
Updating a record

Would someone please look at this code and see what I am doing wrong? The page is used for updating existing records. The user can change one of three inputs and this page receives the from variables, does the calculation and passes them to the sql in the form of variables.

Here is the error message:

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Here a response.write of the sql:

UPDATE otbl_c_d_ProdInfo SET ProHour = '3', CumProd = 44100, UnitProd = 13900, CumMin = 126, MinRan = 39, OEEii = 70 WHERE DTProdId = 49

It is updating data in SQL server with data type for the columns as follows:

ProHour nvarchar
CumProd numeric
UnitProd numeric
MinRan numeric
OEEii Float
DTProdID int identy

Here is the asp

mySql = "UPDATE otbl_c_d_ProdInfo " _
& "SET ProHour = " & "'" & Cstr(Request.Form("txtHour")) & "', " _
& "CumProd = " & CumProd & ", " _
& "UnitProd = " & HrlyProd & ", " _
& "CumMin = " & CumRM & ", " _
& "MinRan = " & HrlyRM & ", " _
& "OEEii = " & Clng(OEEii) & " WHERE DTProdID = " & ProdID
'Response.write(mySql)
cmdUpdate.Execute()
Reply With Quote
  #2 (permalink)  
Old 11-16-02, 23:10
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
What is your db (is it sql server) ? How is CumMin defined ? Give the precision and scale for each numeric.
Reply With Quote
  #3 (permalink)  
Old 11-16-02, 23:12
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
I reread your post and see that you are using sql server - have you tried that update statement in query analyzer ?
Reply With Quote
  #4 (permalink)  
Old 11-17-02, 12:03
clinel clinel is offline
Registered User
 
Join Date: Oct 2002
Location: Western part of Georgia, USA
Posts: 123
Quote:
Originally posted by rnealejr
I reread your post and see that you are using sql server - have you tried that update statement in query analyzer ?
I used the return of the response.write on the cmd page to type in the sql statement into the query analyzer. It ran with no errors.

I mis-stated the data type of ProHour, it is numeric as well. I wraped the value (3) in single quotes and no quotes in the analyzer and it ran both ways. I took the single quotes out of the asp however.

All numeric fields are of percision 10 and scale 0 (default).

Here is how I calculating and passing value to the variables I added the Clng latter just grasping at straws.

Dim TotProd
TotProd = (rsGtVar.Fields.Item("Prod").Value)
If IsNull(TotProd) Then TotProd = 0
Dim TotRM
TotRM = (rsGtVar.Fields.Item("RM").Value)
If IsNull(TotRM) Then TotRM = 0
Dim HrlyProd
Dim CumProd
CumProd = request.form("txtProd")
HrlyProd = Clng(CumProd) - Clng(TotProd)
Dim HrlyRM
Dim CumRM
CumRM = request.form("txtRM")
HrlyRM = Clng(CumRM) - Clng(TotRM)
Dim STDRM
STDRM = 60
ProdID = Session("ProdID")

Thanks,
Lee
Reply With Quote
  #5 (permalink)  
Old 11-17-02, 12:05
clinel clinel is offline
Registered User
 
Join Date: Oct 2002
Location: Western part of Georgia, USA
Posts: 123
I am sorry, I left the oee calculation off

'==============================
'Calculate Oee
Dim OEEii
Dim Speedhdr
Dim Hourhdr
Dim Denom
Hourhdr = Clng(request.form("txtHour"))
if Hourhdr = 0 then hourhdr = 1
Speedhdr = (rsSPD.Fields.Item("SPD").Value)
If isNull(Speedhdr) then Speedhdr = 0
If Speedhdr = 0 Then OEEii = 0
If Speedhdr <> 0 Then
Denom = Hourhdr*60*Speedhdr
End If
Reply With Quote
  #6 (permalink)  
Old 11-26-02, 18:09
brandonh6k brandonh6k is offline
Registered User
 
Join Date: Nov 2002
Posts: 11
Your code:

mySql = "UPDATE otbl_c_d_ProdInfo " _
& "SET ProHour = " & "'" & Cstr(Request.Form("txtHour")) & "', " _
& "CumProd = " & CumProd & ", " _
& "UnitProd = " & HrlyProd & ", " _
& "CumMin = " & CumRM & ", " _
& "MinRan = " & HrlyRM & ", " _
& "OEEii = " & Clng(OEEii) & " WHERE DTProdID = " & ProdID
'Response.write(mySql)
cmdUpdate.Execute()

Try changing this line -

& "OEEii = " & Clng(OEEii) & " WHERE DTProdID = " & ProdID

to:

& "OEEii = " & CDbl(OEEii) & " WHERE DTProdID = " & ProdID

Since OEEii is defined as a Float in the SQL Server, not a Long.

Hope this helps...
__________________
- Brandon
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On