Wrox Home  
Search P2P Archive for: Go

  Return to Index  

proasp_howto thread: Re: Problems with inserting Date parameter


Message #1 by Mark Eckeard <meckeard2000@y...> on Sun, 3 Feb 2002 11:04:25 -0800 (PST)
Mark,

a) What type of field are you trying to insert this date into?
b) Secondly, what is the value that you are trying to insert?
c) Do you still have the problem if you format the date into ISO date
format: yyyy/mm/dd hh:mm:ss
d) Please use the named ADO constants - using "magic numbers" is not a good
idea, since it's too easy to pick the wrong number.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Mark Eckeard" <meckeard2000@y...>
Subject: [proasp_howto] Re: Problems with inserting Date parameter


: Ravi,
:
: OK, here you go:
:
: <START>
: CREATE procedure FCI_i_InsertDRCRMemo
: /*
: SP that inserts newly created dr/cr memos into the
: database. We use a 1 as a dr, 2 as a cr.
: called by: admindc.asp
: */
:
: @strCustomer_ID int,
: @strDRCR int,
: @strAmount money,
: @strDateEntered datetime,
: @strMemo varchar(255),
: @ErrorCode int output
: AS
: declare
: @SQLErrorCode int
: begin tran InsertDRCRMemo
:
: insert into FCI_DRCRMemo
: (Customer_ID, DRCR, Amount, Memo)
: values
: (@strCustomer_ID, @strDRCR, @strAmount, @strMemo)
:
: set @SQLErrorCode = @@error
:
: /*Check for an error. If present, rollback & make NO
: inserts */
: if @SQLErrorCode <> 0
: begin
: rollback tran InsertDRCRMemo
: set @ErrorCode = 1
: return
: end
: commit tran InsertDRCRMemo
: set @ErrorCode = 0
: return
: GO
: </START>
:
: Thanks,
: Mark
: --- RaviKumar Gurrapu <mail2grk@y...> wrote:
: > Mark
: >
: >   I am sorry, could u post code of
: > FCI_i_InsertDRCRMemo stored procedure
: > declaration with parameters.
: >
: > Thanks
: > Ravi
: >
: > > Ravi,
: > >
: > > Here is it:
: > >
: > > <START>
: > > Function InsertDRCRMemo(strCustID, strDrorCr,
: > > strAmount, strDate, strMemo)
: > > 'This function gets some info pertaining to a memo
: > and
: > > inserts them into the
: > > 'database.
: > >
: > > Dim connObj, commObj, RSObj
: > >
: > > 'Create our recordset object.
: > > Set RSObj = Server.CreateObject("ADODB.Recordset")
: > >
: > > 'Set our connection string to a variable.
: > > connStr = Application("ConnectionString")
: > >
: > > 'Create our cmd & conn objects.
: > > Set commObj = server.CreateObject("ADODB.Command")
: > > Set connObj 
: > server.CreateObject("ADODB.Connection")
: > >
: > > server.ScriptTimeout = 690
: > > connObj.CursorLocation = 3      'adUseClient
: > > connObj.ConnectionTimeout = 30
: > > connObj.CommandTimeout = server.ScriptTimeout - 15
: > > 'stop the execution 15 seconds before the page
: > times
: > > out
: > >
: > > 'Open our connection.
: > > connObj.Open connStr
: > >
: > > Set CommObj.ActiveConnection = ConnObj
: > > CommObj.CommandText = "FCI_i_InsertDRCRMemo"
: > > CommObj.CommandType = 4 'adCmdStoredProc
: > >
: > >
: > > 'Set parameter.
: > > Set param = CommObj.CreateParameter("Customer_ID",
: > 3,
: > > 1, , strCustID)
: > > CommObj.Parameters.Append param
: > >
: > > 'Set parameter.
: > > Set param = CommObj.CreateParameter("DRCR", 3, 1,
: > ,
: > > strDrorCr)
: > > CommObj.Parameters.Append param
: > >
: > > 'Set parameter.
: > > Set param = CommObj.CreateParameter("Amount", 6,
: > 1, ,
: > > strAmount)
: > > CommObj.Parameters.Append param
: > >
: > > '*********** Here is the line in question ******
: > > Set param = CommObj.CreateParameter("DateEntered",
: > 7,
: > > 1, , cdate(strDate))
: > > CommObj.Parameters.Append param
: > >
: > > 'Set parameter.
: > > Set param = CommObj.CreateParameter("Memo", 200,
: > 1,
: > > 255, strMemo)
: > > CommObj.Parameters.Append param
: > >
: > > 'Set parameter.
: > > Set param = CommObj.CreateParameter("ErrorCode",
: > 5, 2,
: > > 0, ErrorCode) 'DOUBLE/NUMBER, OUT
: > > CommObj.Parameters.Append param
: > >
: > > 'Execute.
: > > Set RSObj = commObj.Execute()
: > >
: > > 'Destroy our command object.
: > > set commObj = nothing
: > >
: > > 'Close & destroy our connection object.
: > > connObj.Close
: > > Set connObj = Nothing
: > >
: > > end function  'InsertDRCRMemo
: > > </START>
: > >
: > > Mark



  Return to Index