+ Reply to Thread
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 39

Thread: Recordset and Stored Procedure issues!

  1. #21
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    436
    Rep Power
    7

    i believe it should. i mean, i've run stored procs like you're trying and have not had an issue, but i have switched to doing the command object. it's better ... and it helps to prevent sql injection as well.
    Quote of the Month:
    Leaders: Leaders are like eagles. We don't have either of them here.

    Questions to Ponder:
    Why do banks charge you a "non-sufficient funds fee" on money they already know you don't have?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  2. #22
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    1,037
    Blog Entries
    2
    Rep Power
    13

    Well there ya are then, that's a right mess. Is should be:
    Exec spTestEdit1 'test@test.com'. If the user name is be retrieved as test@test.com then all you need do is: [b]sql = "Exec spTestEdit1 'test@test.com'

    [footnote] Sorry, got interrupted with a production problem and there were a few posts while I was gone.
    Wolffy
    ------------------------
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #23
    Barn Enthusiast Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    429
    Rep Power
    2

    Quote Originally Posted by mehere View Post
    i believe it should. i mean, i've run stored procs like you're trying and have not had an issue, but i have switched to doing the command object. it's better ... and it helps to prevent sql injection as well.
    <%Option explicit

    Dim cmd, rs, connect, intNumber
    Const adCmdStoredProc = &H0004
    Const adParamInput = &H0001
    Const adParamOutput = &H0002
    Const adVarChar = 200
    Const adInteger = 3

    Set cmd = Server.CreateObject ("ADODB.Command")
    connect = "Provider=SQLOLEDB;Persist Security Info=False;User ID=sa; &;Password=test;" &_
    "Initial Catalog=coursesSQL;Data Source=xxxxxxxxxx"

    cmd.ActiveConnection = connect
    cmd.CommandText = "spTestEdit1 "
    cmd.CommandType = adCmdStoredProc
    cmd.Parameters.Append cmd.CreateParameter &_
    ("@username",adInteger,adParamOutput)
    Set rs = cmd.Execute

    intNumber = comm.Parameters("@username")
    set cmd = nothing
    %>

    i place this? in my asp page???????????

  4. #24
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    436
    Rep Power
    7

    since @username is an email address, you wouldn't use adInteger, but instead adVarChar along with the number of characters. something like this:
    Code:
    cmd.Parameters.Append cmd.CreateParameter &_
    ("@username",adVarChar,50,adParamOutput,session("username"))
    
    Quote of the Month:
    Leaders: Leaders are like eagles. We don't have either of them here.

    Questions to Ponder:
    Why do banks charge you a "non-sufficient funds fee" on money they already know you don't have?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  5. #25
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    1,037
    Blog Entries
    2
    Rep Power
    13

    Sort of like that. However, username is neither an integer nor an output so:
    Code:
    cmd.Parameters.Append cmd.CreateParameter &_
          ("@username",advarchar,adParamInput, 50)
    
    I think I got that right anyway.

    I would then have the stored procedure return the primary key value for the username (you do have a PK on this table right, which should be an identity column) as an output parameter, or have it return -1 for user not found.

    [edit] and I like mehere's better, since it sets the value of the parameter too and saves a step.[/edit]
    Last edited by Wolffy; June 23rd, 2009 at 11:37 AM.
    Wolffy
    ------------------------
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.

  6. #26
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    1,037
    Blog Entries
    2
    Rep Power
    13

    Thus, your stored procedure would become something like:
    Code:
    Create procedure spTestEdit1  (
        @username varchar(20)
      , @userID   int output
    )
    as
        Set @userID = NULL
        SELECT  @userID = [TEST-1]
         FROM [dbo].[TEST-1]
        WHERE username=@username
    
        If @userID is Null Set @userID = -1
    
    Wolffy
    ------------------------
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.

  7. #27
    Barn Enthusiast Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    429
    Rep Power
    2

    Quote Originally Posted by mehere View Post
    since @username is an email address, you wouldn't use adInteger, but instead adVarChar along with the number of characters. something like this:
    Code:
    cmd.Parameters.Append cmd.CreateParameter &_
    ("@username",adVarChar,50,adParamOutput,session("username"))
    
    Quote Originally Posted by Wolffy View Post
    Sort of like that. However, username is neither an integer nor an output so:
    Code:
    cmd.Parameters.Append cmd.CreateParameter &_
          ("@username",advarchar,adParamInput, 50)
    
    I think I got that right anyway.

    I would then have the stored procedure return the primary key value for the username (you do have a PK on this table right, which should be an identity column) as an output parameter, or have it return -1 for user not found.

    [edit] and I like mehere's better, since it sets the value of the parameter too and saves a step.[/edit]
    im lost here, which one do i use???????

  8. #28
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    436
    Rep Power
    7

    using mine will pass in the value for the parameter ... also, i transposed 2 of the values, and used output instead of input ... see changes below.
    Code:
    cmd.Parameters.Append cmd.CreateParameter &_
    ("@username",adVarChar,adParamInput,50,session("username"))
    
    Quote of the Month:
    Leaders: Leaders are like eagles. We don't have either of them here.

    Questions to Ponder:
    Why do banks charge you a "non-sufficient funds fee" on money they already know you don't have?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  9. #29
    Barn Enthusiast Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    429
    Rep Power
    2

    line 8 error:

    Name redefined

    this is line 8 :

    Code:
    Const adCmdStoredProc = &H0004
    

  10. #30
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    436
    Rep Power
    7

    do you have an include file like adovbs.inc on your page? if so, remove your const lines.
    Quote of the Month:
    Leaders: Leaders are like eagles. We don't have either of them here.

    Questions to Ponder:
    Why do banks charge you a "non-sufficient funds fee" on money they already know you don't have?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

+ Reply to Thread
Page 3 of 4 FirstFirst 1 2 3 4 LastLast

Similar Threads

  1. SQL Job or stored procedure
    By todd2006 in forum SQL Development
    Replies: 5
    Last Post: February 11th, 2009, 02:20 PM
  2. stored procedure
    By todd2006 in forum ASP Development
    Replies: 7
    Last Post: February 5th, 2009, 03:02 PM
  3. stored procedure
    By todd2006 in forum Microsoft SQL Server
    Replies: 1
    Last Post: February 5th, 2009, 01:25 PM
  4. If statement stored procedure
    By peebman2000 in forum SQL Development
    Replies: 32
    Last Post: May 23rd, 2008, 03:54 PM
  5. Dynamic Stored Procedure
    By jmurrayhead in forum Microsoft SQL Server
    Replies: 16
    Last Post: March 26th, 2008, 11:19 AM

Bookmarks

Posting Permissions

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

SEO by vBSEO