Results 1 to 11 of 11

Thread: [RESOLVED] Stored Procedures with Parameters using ADO

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    230

    Resolved [RESOLVED] Stored Procedures with Parameters using ADO

    I have a stored procedure that is like this

    VB Code:
    1. CREATE PROCEDURE usp_insertPatternData
    2. @DateTime datetime,
    3. @laserNumber tinyint,
    4. @Operator varchar(10),
    5. @LotID varchar(10),
    6. @WaferNumber    tinyint,
    7. @ExposureTime tinyint,
    8. @TimeDelay tinyint,
    9. @LeftDiode int,
    10. @RightDiode int,
    11. @TopDiode int,
    12. @BottomDiode int,
    13. @CenterDiode int,
    14. @LeftOffset int,
    15. @RightOffset int,
    16. @TopOffset int,
    17. @BottomOffset int,
    18. @PowerTrackStatus tinyint,
    19. @Current float,
    20. @TubeHours float,
    21. @AperturePosition float,
    22. @TEMoo tinyint,
    23. @EtalonMode tinyint,
    24. @PTDACA tinyint,
    25. @PTDACB tinyint,
    26. @AutofillDelta float,
    27. @HeadHours float,
    28. @CathodeVoltage float,
    29. @CathodeCurrent float,
    30. @MagnetCurrent float
    31.  
    32. AS
    33.  
    34. set nocount on
    35.  
    36. INSERT INTO Patterning ( dateTime, laserNumber, Operator, LotID, WaferNumber, ExposureNumber, TimeDelay, LeftDiode, RightDiode, TopDiode, BottomDiode, CenterDiode, LeftOffset, RightOffset, TopOffset, BottomOffset, PowerTrackStatus, [Current], TubeHours, AperturePosition, TEMoo, EtalonMode, PTDACA, PTDACB, AutofillDelta, HeadHours, CathodeVoltage, CathodeCurrent, MagnetCurrent)
    37. VALUES (@dateTime, @laserNumber, @Operator, @LotID, @WaferNumber, @ExposureTime, @TimeDelay, @LeftDiode, @RightDiode, @TopDiode, @BottomDiode, @CenterDiode, @LeftOffset, @RightOffset, @TopOffset, @BottomOffset, @PowerTrackStatus, @Current, @TubeHours, @AperturePosition, @TEMoo, @EtalonMode, @PTDACA, @PTDACB, @AutofillDelta, @HeadHours, @CathodeVoltage, @CathodeCurrent, @MagnetCurrent );
    38. GO

    and I am trying to pass these parameters in my VB6 code like this:

    VB Code:
    1. Private dbConnPatterning As ADODB.Connection
    2. Private dbCommand As ADODB.Command
    3.  
    4.  
    5. Private Sub Form_Load()
    6.  
    7.     Set dbConnPatterning = New ADODB.Connection
    8.     dbConnPatterning.Provider = "sqloledb"
    9.     Set dbCommand = New ADODB.Command
    10.     dbCommand.CommandText = "usp_insertPatternData"
    11.     dbCommand.CommandType = adCmdStoredProc
    12.    
    13.     dbConnPatterning.Open "server=esp\opt;uid=tyler1;pwd=password;database=Patterning"
    14.     dbCommand.Parameters.Item(0).Value = Now
    15.     dbCommand.Parameters.Item(1).Value = 1
    16.     dbCommand.Parameters.Item(2).Value = "abc"
    17.     dbCommand.Parameters.Item(3).Value = "abc"
    18.     dbCommand.Parameters.Item(4).Value = 1
    19.     dbCommand.Parameters.Item(5).Value = 10
    20.     dbCommand.Parameters.Item(6).Value = 2
    21.     dbCommand.Parameters.Item(7).Value = 10
    22.     dbCommand.Parameters.Item(8).Value = 10
    23.     dbCommand.Parameters.Item(9).Value = 10
    24.     dbCommand.Parameters.Item(10).Value = 10
    25.     dbCommand.Parameters.Item(11).Value = 10
    26.     dbCommand.Parameters.Item(12).Value = 5
    27.     dbCommand.Parameters.Item(13).Value = 5
    28.     dbCommand.Parameters.Item(14).Value = 5
    29.     dbCommand.Parameters.Item(15).Value = 5
    30.     dbCommand.Parameters.Item(16).Value = 1
    31.     dbCommand.Parameters.Item(17).Value = 2.2
    32.     dbCommand.Parameters.Item(18).Value = 1200
    33.     dbCommand.Parameters.Item(19).Value = 4
    34.     dbCommand.Parameters.Item(20).Value = 4
    35.     dbCommand.Parameters.Item(21).Value = 4
    36.     dbCommand.Parameters.Item(22).Value = 1
    37.     dbCommand.Parameters.Item(23).Value = 1
    38.     dbCommand.Parameters.Item(24).Value = 10.2
    39.     dbCommand.Parameters.Item(25).Value = 1200
    40.     dbCommand.Parameters.Item(26).Value = 12.2
    41.     dbCommand.Parameters.Item(27).Value = 4.5
    42.     dbCommand.Parameters.Item(28).Value = 6.8
    43.     dbCommand.Execute
    44.     dbConnPatterning.Close
    45.    
    46.    
    47. End Sub

    I thought that might work, but it doesn't. I came across some code that does something like this

    VB Code:
    1. ' Set up a new parameter for the stored procedure.
    2. Set prm = Cmd.CreateParameter("CategoryID", adInteger, adParamInput, 4, 7)
    3. Cmd.Parameters.Append prm

    Is this what I should be doing? I'm accustomed to using stored procedures with ADO.NET and this seems to be quite different than

    mySqlComm.parameters.add("@LotID", me.txtLotID.text)

    which is what you do in ADO.NET. Could that be right?
    Last edited by just_a_me; Feb 16th, 2006 at 11:15 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width