Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123

    Unanswered: 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()

  2. #2
    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.

  3. #3
    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 ?

  4. #4
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    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

  5. #5
    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

  6. #6
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •