New to ASP, getting an error

  • Hi,

    I am getting an error while compiling:

    No value given for one or more required parameters

    The code I am getting this error on is:

    ---------------------------------------------------------------

    rs.open "SELECT @@IDENTITY AS NEW_ID FROM TB_ATTACHMENTS", dbconnection

    if not rs.EOF then

    thisID = trim(rs("NEW_ID"))

    mySQLDMZ = "INSERT INTO TB_ATTACHMENTS (ATTACHMENT_ID, ATTACHMENT_TYPE, ATTACHMENT_TITLE, ATTACHMENT_SIZE, ATTACHMENT_NAME, ATTACHMENT, ATTACHMENT_HASH) VALUES ('" & thisID & "', " &_

    "1," &_

    "'" & Session("title0" & fI) & "'," &_

    "'" & Session("fileSize0" & fI) & "'," &_

    "'" & Session("fileName0" & fI) & "'," &_

    "?," &_

    "'" & Session("hash0" & fI) & "')"

    dbconnectionDMZ.execute(mySQLDMZ)

    rs.close

    end if

    ------------------------------------------------------------------

    Could someone pls help me in this regard ?

  • One of the parameters seems to be missing a value, impossible for us to tell which one.

    I would however re-write this code to use a stored proc, rather than bulding up a sql statment with parameters.

  • Connection.Execute(sqlStatement) optionally returns a dataset. use that to get uthe update and the results in one pass.

    i would use a two statement combo like this:

    dim Conn ' As Object

    set Conn = Server.Createobject("ADODB.Connection")

    Conn.ConnectionString = "PROVIDER=SQLOLEDB;DATA SOURCE=D223;UID=WebUser;PWD=NotARealpassword;DATABASE=SandBox;"

    Conn.Open

    Dim MyRs 'As ADODB.Recordset

    Set MyRs = Server.CreateObject("ADODB.Recordset")

    MyRs.CursorLocation = 3 'adUseClient

    dim sql 'As String

    sql = "INSERT INTO [snipped for brevity]" & ";"

    sql = sql & "SELECT SCOPE_IDENTITY(); As NEWID"

    Set MyRs = Conn.Execute(sql)

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply