Strings

Results 1 to 4 of 4

Thread: Strings

  1. #1
    KP Guest

    Default Strings

    I am trying to pass a string through to a stored procedure.<BR>The filed in the database is a data type &#039;int&#039;, and I am declaring it as an &#039;int&#039; and the stored procedure states it is an &#039;int&#039; value. But it errors. It&#039;s not accepting &#039;CInt&#039;. I am at my wits end. Is there anything else I can declare it as as it&#039;s reading it as a varchar character at the moment.

  2. #2
    Join Date
    Dec 1969
    Posts
    3,921

    Default Post your ADO code...

    ...

  3. #3
    KP Guest

    Default RE: Post your ADO code...

    Dim strID<BR><BR>strID = Request.QueryString("InNum")<BR><BR>Set oCmd = Server.CreateObject("ADODB.Command")<BR>oCmd.Activ eConnection = "dsn=*****;uid=***;pwd=;database=****"<BR>oCmd.Com mandText = "usp_history"<BR>oCmd.CommandType = 4<BR>strNameValue = Request.QueryString("InNum")<BR><BR>Set oParam = oCmd.CreateParameter("@ID")<BR>oParam.Type = adInteger<BR>oParam.Direction = adParamInput<BR>oParam.Size = Len(strNameValue)<BR>oParam.Value = (strID) <BR><BR>oCmd.Parameters.Append oParam <BR><BR>Through to SP:<BR><BR>CREATE PROCEDURE usp_History<BR> @ID Integer<BR> AS<BR>SELECT @ID = @ID <BR><BR>SELECT * FROM dbo.Problem<BR>WHERE [problem number] = @ID<BR>GO<BR><BR>Can you help?

  4. #4
    Join Date
    Dec 1969
    Posts
    3,921

    Default Don't know the specific error but...

    ... but you might try this:<BR><BR>moADOCom is your command object. moADOCon is your connection object.<BR><BR> With moADOCom<BR> .ActiveConnection = moADOCon &#039; connection object<BR> .CommandText = "usp_History"<BR> .CommandType = adCmdStoredProc<BR> .Parameters.Append .CreateParameter("RC", adInteger, adParamReturnValue)<BR> .Parameters.Append .CreateParameter("@ID", adInteger, adParamInput, 0, strNameValue)<BR><BR> .Execute <BR> End With<BR><BR> Integers should not have lengths assigned to them. Put this in at the top of your global.asa so you can use the ADO constants.<BR><BR>&#060;!--METADATA NAME="Microsoft ActiveX Data Objects 2.5 Library" TYPE="TypeLib" UUID="{00000205-0000-0010-8000-00AA006D2EA4}"--&#062;<BR><BR>Store your connection string for the connection object in your application variable in the global.asa. Looks like you are using SQL Server and SQLOLEDB connections are much more efficient than ODBC and require no ADO code changes to use.<BR><BR>Application("strConn")= "Provider=SQLOLEDB;Data Source=(local);User ID=myuser;Password=mypwd;Initial Catalog=MYDB"<BR><BR>Also, in the store procedure, SELECT @ID = @ID is not necessary.<BR><BR>One last thing, why are you attempting to use a command object to pull back a query? Why not use the recordset object?


Posting Permissions

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