Results 1 to 11 of 11

Thread: Creating And Using Stored Procedures ??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240
    Hi,
    Lately I've been hearing all these talks about Stored Procedures for database. I'm using VB6, can someone explain to me how to create and use Stored Procedures.

    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    Stored procedures are From the database, and are used to store a SQL statement that can be used over and over again without having to keep on writing it in your code. The statement can be any SQL statement (select, insert, update etc).

    If You are using Microsoft SQL server then they are quite easy to create and you can find all the information you need on books online.

    With Access they are not actually called Stored procedures but when you save a query you are still doing pretty much the same thing.

    Both with access and SQL these can be used within VB by calling them instead of tables.

    If you have any particular questions you want to ask reply back.

    Good Luck

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240
    Hi,
    Is there a way to create and use Stored procedures in VB?
    If so, How?

    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    You probably want to create your stored procedures using the GUI for your DBMS.... what DBMS are you using?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    How Can I Implement it in VB ??

    Hi,
    Is Access 97 a DMS. I just want to know how to write a program that uses stored procedures. How can I do that???
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  6. #6
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Access 97 doesn't have/use stored procedures.


  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    How Can I create and Use Stored Procedures??

    Hi,
    All I want to know is How Can I create and Use Stored Procedures In VB that all.

    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  8. #8
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124
    You do not want to create a Stored Procedure in VB. The Stored Procedure resides in you database. If you are accessing the database via a network then you want to use stored procedures as much as possible. The stored procedure is compiled and executed on the server. You can execute a stored procedure from VB though using DAO, RDO, or ADO.

  9. #9
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    It's going to depend on the DBMS you use. You're asking the equivalent of "How do I code a text parser, in any language?".

    For SQL Server 6.5, in another thread I wrote this stored procedure to replace an IIF command the person was using in Access:

    Code:
    if exists (select * from sysobjects where id = object_id('dbo.cp_getWeekDay') and sysstat & 0xf = 4)
    	drop procedure dbo.cp_getWeekDay
    GO
    CREATE PROCEDURE cp_getWeekDay
    as
    
    
    create table #tempWkDay (
           DT_Import smallint not null,
    	DayImport char(6))
    
    insert into #tempWkDay SELECT DT_Import, "Monday" FROM tMaster where dt_import=2
    insert into #tempWkDay SELECT DT_Import, "Other" FROM tMaster where dt_import not = 2
    
    
    SELECT * from #tempWkDay
    GO
    To create it, in VB (if it's even possible), you would send the entire code to SQL server via passthru.

    To execute it, you would need to send a passthru SQL command:

    cp_getWeekDay

    [Edited by JHausmann on 04-05-2000 at 03:46 PM]

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    I'm not too clear !!

    Hi,
    One of the things that I think got me confused was the idea Stored Procedure. Probably I'm taking it too literal but to me it seems as if Stored Procedures are stored inside the vb executable file, you could then use DAO, RDO, or ADO to access them.
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  11. #11
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Stored pocedures are stored in the DBMS. You can use ADO/DAO/RDo to access them. As far as VB is concerned, it's the same as any other SQL command, almost.

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