Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Stored Procedure Part 2


Reply
 
Thread Tools Display Modes
  #1  
Old 04-21-2004, 06:11 AM
RedLeader's Avatar
RedLeader RedLeader is offline
Centurion
 
Join Date: Jan 2004
Location: Bulgaria
Posts: 121
Default Stored Procedure Part 2


Hi ,
I try to do INSERT INTO mytable ........from RandomName table with Stor.Proc.
SQL7 server Stored procedure:
Code:
CREATE PROCEDURE [prcINS]
 	@varName varchar(100),
        @varTable varchar(100)
 AS 
 Insert Into zzz1 (zz, z)  Select zz, z From @varTable Where z= @varName
VB code
Code:
rdb.execute("prcINS @varTable='R324544',@varName='3'")
and the problem is :
Invalid object name @varTable

Thank`s

Last edited by RedLeader; 04-21-2004 at 06:21 AM.
Reply With Quote
  #2  
Old 04-21-2004, 09:57 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

OK, where do you actually create the table. Here is a sample script, it creates two table and then populates them via insert into:

Code:
CREATE TABLE Table1 (id IDENTITY, x CHAR(100), numx DOUBLE)

CREATE TABLE Table2 (id IDENTITY, x CHAR(100), numx DOUBLE)

CREATE PROCEDURE Proc1(:vc CHAR(100)) AS 
   BEGIN
      DECLARE :vd DOUBLE;
      DECLARE C1 CURSOR FOR SELECT numx FROM Table1 WHERE x = :vc;
      OPEN C1;
      FETCH NEXT FROM C1 INTO :vd;
      INSERT INTO Table2(id, x, numx) VALUES (0, :vc, :vd);
      CLOSE C1;
   END
   
   INSERT INTO Table1 VALUES (0, 'A Text', 1)

   CALL Proc1('A')
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #3  
Old 04-22-2004, 02:39 AM
RedLeader's Avatar
RedLeader RedLeader is offline
Centurion
 
Join Date: Jan 2004
Location: Bulgaria
Posts: 121
Default

Thank you MKoslof
Reply With Quote
  #4  
Old 04-22-2004, 06:26 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

No problem, always glad to help.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
stored procedure maggie Database and Reporting 0 12-12-2003 11:04 AM
Stored Procedure Newbie thiamhong Database and Reporting 3 11-28-2003 05:35 AM
Subscript out of range when calling stored procedure mikechan8888 Database and Reporting 6 07-24-2003 06:33 PM
Help needed: Problems with stored procedure and cursors cesian Database and Reporting 2 06-27-2003 04:07 PM
Stored Procedure: Pass in Field Names? diver Database and Reporting 0 09-26-2002 04:40 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->