Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Insert Statement Error

Options
  • 13-12-2011 4:16pm
    #1
    Registered Users Posts: 224 ✭✭


    Hi,

    Im getting an error when i try to insert a recordset. Im using asp vb script and ms sql server db. Ill add the relevant insert statement code below. All the fields im trying to insert are integers. Any help here would be much appreciated. :eek:

    ===============================================
    Here is the insert statement.
    [HTML]

    <%
    If (CStr(Request("MM_insert")) = "form1") Then
    If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_ithubconn_STRING
    MM_editCmd.CommandText = "INSERT INTO dbo.tblDailyJobs (JobDescID, DailyJobDescID, UserId, Archive, StatusID) VALUES (?, ?, ?, ?, ?)"
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("JobDescID"), Request.Form("JobDescID"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("ddJobDesc"), Request.Form("ddJobDesc"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, -1, MM_IIF(Request.Form("UserID"), Request.Form("UserID"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 5, 1, -1, MM_IIF(Request.Form("archive"), Request.Form("archive"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 5, 1, -1, MM_IIF(Request.Form("StatusID"), Request.Form("StatusID"), null)) ' adDouble
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "cfmDailyJob.asp"
    If (Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
    MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
    MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
    End If
    Response.Redirect(MM_editRedirectUrl)
    End If
    End If
    %>

    'The RECORDSETS
    <%
    Dim rsInsDailyJob
    Dim rsInsDailyJob_cmd
    Dim rsInsDailyJob_numRows

    Set rsInsDailyJob_cmd = Server.CreateObject ("ADODB.Command")
    rsInsDailyJob_cmd.ActiveConnection = MM_ithubconn_STRING
    rsInsDailyJob_cmd.CommandText = "SELECT * FROM dbo.tblJobCategory ORDER BY JobDesc ASC"
    rsInsDailyJob_cmd.Prepared = true

    Set rsInsDailyJob = rsInsDailyJob_cmd.Execute
    rsInsDailyJob_numRows = 0
    %>

    <%
    Dim RsJobDescDD__typeid
    RsJobDescDD__typeid = "0"
    If (Request.QueryString("typeid") <> "") Then
    RsJobDescDD__typeid = Request.QueryString("typeid")
    End If
    %>
    <%
    Dim RsJobDescDD
    Dim RsJobDescDD_cmd
    Dim RsJobDescDD_numRows

    Set RsJobDescDD_cmd = Server.CreateObject ("ADODB.Command")
    RsJobDescDD_cmd.ActiveConnection = MM_ithubconn_STRING
    RsJobDescDD_cmd.CommandText = "SELECT * FROM dbo.tblDailyJobDesc WHERE JobDescID=?"
    RsJobDescDD_cmd.Prepared = true
    RsJobDescDD_cmd.Parameters.Append RsJobDescDD_cmd.CreateParameter("param1", 5, 1, -1, RsJobDescDD__typeid) ' adDouble

    Set RsJobDescDD = RsJobDescDD_cmd.Execute
    RsJobDescDD_numRows = 0
    %>

    'Here is the form

    <form action="<%=MM_editAction%>" method="POST" id="form1" name="form1">
    <label>
    <select name="JobDescID" id="JobDescID" onchange="MM_jumpMenu('parent',this,0)">
    <option value="copy of home.asp?typeid=0">TASK</option>
    <%
    While (NOT rsInsDailyJob.EOF)
    %>
    <option value="copy of home.asp?typeid=<%=(rsInsDailyJob.Fields.Item("JobDescID").Value)%>" <%If CInt(Request.QueryString("typeid"))=rsInsDailyJob("JobDescID") Then Response.Write"selected"%>><%=(rsInsDailyJob.Fields.Item("JobDesc").Value)%></option>
    <%
    rsInsDailyJob.MoveNext()
    Wend
    If (rsInsDailyJob.CursorType > 0) Then
    rsInsDailyJob.MoveFirst
    Else
    rsInsDailyJob.Requery
    End If
    %>
    </select>
    </label>

    <label>
    <select name="ddJobDesc" id="ddJobDesc" onchange="">
    <%
    While (NOT RsJobDescDD.EOF)
    %>
    <option value="<%=RsJobDescDD("DailyJobDescID")%>"><%=(RsJobDescDD.Fields.Item("DailyJobDesc").Value)%></option>
    <%
    RsJobDescDD.MoveNext()
    Wend
    If (RsJobDescDD.CursorType > 0) Then
    RsJobDescDD.MoveFirst
    Else
    RsJobDescDD.Requery
    End If
    %></select>
    </label>
    <select name="UserID" id="UserID">
    <option value="0">User</option>
    <%
    While (NOT rsInsUser.EOF)
    %>
    <option value="<%=(rsInsUser.Fields.Item("UserID").Value)%>"><%=(rsInsUser.Fields.Item("FullName").Value)%></option>
    <%
    rsInsUser.MoveNext()
    Wend
    If (rsInsUser.CursorType > 0) Then
    rsInsUser.MoveFirst
    Else
    rsInsUser.Requery
    End If
    %>
    </select>
    <br />
    <input name="archive" type="hidden" id="archive" value="0" />
    Status</span></td>

    <select name="StatusID" id="StatusID">
    <option value="0">Status</option>
    <%
    While (NOT rsStatus.EOF)
    %>
    <option value="<%=(rsStatus.Fields.Item("StatusID").Value)%>"><%=(rsStatus.Fields.Item("StatsusDesc").Value)%></option>
    <%
    rsStatus.MoveNext()
    Wend
    If (rsStatus.CursorType > 0) Then
    rsStatus.MoveFirst
    Else
    rsStatus.Requery
    End If
    %>
    <input type="submit" name="button" id="button" value="Submit" />
    <input type="hidden" name="MM_insert" value="form1" />
    </form>

    [/HTML]
    =====================================================
    The error is as follows

    ADODB.Command (0x800A0D5D)
    Application uses a value of the wrong type for the current operation.
    /ithub/copy of home.asp, line 150.

    This error points to this line->

    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("JobDescID"), Request.Form("JobDescID"), null)) ' adDouble
    +++++++++++++++++++++++++++++++++++++++++++++++++++++


Comments

  • Registered Users Posts: 11,979 ✭✭✭✭Giblet


    Identity Column insert attempt? Try removing Param1.


  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    Thats it alright.

    thanks


Advertisement