To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Database Development

Reply Post New Thread
 
Thread Tools Display Modes
Old May 28th, 2000, 07:49 PM   #1
mutley
Fanatic Member
 
mutley's Avatar
 
Join Date: Apr 00
Location: Sao Paulo - Brazil
Posts: 560
mutley is an unknown quantity at this point (<10)
Question

Hi


I tried call 2 Storeds Procedures from VB wich front-end


The first Stored Procedure give an error message


RUN-TIME ERROR '-2147217900'

PROCEDURE MEUTESTE HAS NO PARAMETERS AND ARGUMENTS WERE SUPPLIED

-------------------------
CREATE PROCEDURE meuteste AS
select ag02_hr_ini,ag02_hr_fim
from ag02

------------------------ x---------------------------

The other Procedure give error :

ADO CAN NOT FOUND COLLECTION OBJECT CORRESPONDING NAME OR REFERENCE ORDINAL


CREATE PROCEDURE sp2_filtramain (@Pdata datetime ,
@Pcd_proc varchar(08))
AS

declare @whr_ini datetime /* Horário Inicial - Cursor */
declare @vhr_ini datetime /* Cópia do horário Inicial */
declare @whr_fim datetime /* Horário Final - Cursor */
declare @vhr_fim datetime /* Cópia Do horário Final */
declare @hora_agenda datetime /* Hora Agendada */
declare @wdata_ini datetime
declare @wdata_fim datetime
declare @wlocal int /* Código do Local - Cursor */
declare @vlocal int /* Cópia do código do local */
declare @wnom_loc varchar(30) /* Nome do Local - Cursor */
declare @vnom_loc varchar(30) /* Cópia do nome do local */
declare @Vstat integer /* Status de retorno */
declare @Whr_dur varchar(6) /* duração */
declare @Vhr_dur integer /* Duração do Exame */
declare @Vcd_rgr integer /* regra */
declare @Vintervalo datetime /* Guarda o Intervalo de cada período */
declare @Vhora integer /*Guarda Hora e Minuto */
declare @Vminuto integer
declare @wccu varchar(4)
declare @Vachou integer
declare @Vret integer
declare @Vdia varchar(02)
declare @Vmes varchar(02)
declare @Vrows integer
declare @Vchar varchar(30)
declare @lflag integer
declare cr_Agenda insensitive cursor /* CURSOR */

FOR
select distinct convert(datetime, convert(varchar, ag02_hr_ini, 14)),
convert(datetime, convert(varchar, ag02_hr_fim, 14)),
ag01_cd_loc,
ag01_nm_loc,
ag01_cd_ccu
from ag02
join ag07
on ag02_cd_rgr = ag07_cd_rgr
join ag18
on ag07_cd_rgr = ag18_cd_rgr and
ag07_cd_ccu = ag18_cd_ccu and
ag07_cd_loc = ag18_cd_loc
join ag01
on ag07_cd_ccu = ag01_cd_ccu and
ag07_cd_loc = ag01_cd_loc
where (ag07_cd_proc = @Pcd_proc) and (ag02_dt_ini_vig <= getdate())
and (ag02_dt_fim_vig>=getdate() or ag02_dt_fim_vig is null)
and (ag02_dia_sem = 2)
order by 3,1

create table #tmp_se_ag08_02 (
hr_ini datetime not null,
hr_fim datetime not null,
sala varchar(30)
)

select @Whr_dur = ag06_hr_dur
from ag06
where ag06_cd_proc = @Pcd_proc

select @Vhora = convert(integer,substring(@Whr_dur,1,2))
select @Vminuto = convert(integer,substring(@Whr_dur,4,2))
select @Vhr_dur = @Vhora*60 + @Vminuto


/* if (@@ROWCOUNT = 0)
begin
select @Vstat = 6
goto ERR_AGENDA
end */
select @Vachou = 0
while @Vachou = 0
begin
--------------------------------------------
-- Verifica se eh um feriado
-------------------------------------------
select @Vchar = convert(varchar, @Pdata)
select @Vdia = convert(varchar, datepart(day, @Pdata))
select @Vmes = convert(varchar, datepart(month, @Pdata))
exec @Vret = sp2_se_ag16_02 @Vdia, @Vmes, NULL, NULL
if (@Vret = 0)
begin
select @Vrows = 0
select @Pdata = dateadd(day, 1, @Pdata)
continue
end
open cr_Agenda

fetch next from cr_Agenda into @Whr_ini, @Whr_fim,@wlocal,@wnom_loc,@Wccu




select @lflag = 0
while (@@FETCH_STATUS = 0)
begin
select @wdata_ini = convert(varchar, @Pdata, 111) + ' ' + convert(varchar, @Whr_ini, 14)
select @wdata_fim = convert(varchar, @Pdata, 111) + ' ' + convert(varchar, @Whr_fim, 14)
select @Vrows = count(ag03_cd_loc) from ag03 where ag03_cd_ccu = @wccu
and ag03_cd_loc = @Wlocal and ((@Wdata_ini between ag03_dth_ini and ag03_dth_fim) or
@Wdata_fim between ag03_dth_ini and ag03_dth_fim)
if @vrows > 0
begin
fetch next from cr_Agenda into @Whr_ini, @Whr_fim,@wlocal,@wnom_loc,@wccu
continue
end
if @lflag<>0
begin
while @vlocal = @wlocal and (@@FETCH_STATUS = 0)
begin
if abs(datediff(n,@vhr_fim,@Whr_ini))<=1
select @Vhr_fim = @Whr_fim
else
begin
select @Vhr_fim = dateadd(n,1,@Vhr_fim)
select @Vintervalo = dateadd(n,@Vhr_dur,@vhr_ini)
while (@Vintervalo <= @Vhr_fim)
begin
select @Vachou =1
insert into #tmp_se_ag08_02 values (@Vhr_ini,@Vintervalo,@vnom_loc)
select @Vhr_ini = @Vintervalo
select @Vintervalo = dateadd(n,@vhr_dur,@Vintervalo)
end -- while intervalo
select @vhr_ini = @whr_ini
select @vhr_fim = @whr_fim
end -- else datediff
fetch next from cr_Agenda into @Whr_ini, @Whr_fim,@wlocal,@wnom_loc,@wccu
end -- while local
select @Vhr_fim = dateadd(n,1,@Vhr_fim)
select @Vintervalo = dateadd(n,@Vhr_dur,@vhr_ini)
while (@Vintervalo <= @Vhr_fim)
begin
select @Vachou = 1
insert into #tmp_se_ag08_02 values (@Vhr_ini,@Vintervalo,@vnom_loc)
select @Vhr_ini = @Vintervalo
select @Vintervalo = dateadd(n,@vhr_dur,@Vintervalo)
end -- while intervalo 2
select @Vhr_ini = @Whr_ini
select @Vhr_fim = @Whr_ini
select @Vnom_loc = @Wnom_loc
select @Vlocal = @Wlocal
end
else
begin
select @Vhr_ini = @Whr_ini
select @Vhr_fim = @Whr_fim
select @Vnom_loc = @Wnom_loc
select @Vlocal = @Wlocal
select @lflag = 1
fetch next from cr_Agenda into @Whr_ini, @Whr_fim,@wlocal,@wnom_loc,@wccu
end
end
close cr_Agenda
deallocate cr_Agenda
select @Pdata = dateadd(day, 1, @Pdata)
end
select substring(convert(varchar,hr_ini,14),1,5) as hora_ini,
substring(convert(varchar, hr_fim,14 ),1,5) as hora_fim, sala from #tmp_se_ag08_02

drop table #tmp_se_ag08_02
---------------------------------------X---------------------------
The 2 Stored Procedures run normal from Query Analyzer

I call Stored Procedures from VB as:

newdata = Format(cdata, "yyyy-mm-dd")
cproc = "ABDS"

sql = "sp2_filtramain('" & newdata & "', '" & cproc & "')"
' or sql = "meuteste()"
With ocmd
' .ActiveConnection = G_Database.ConnectionString
.ActiveConnection = SQLSERVER.ConnectionString

.CommandText = sql
.CommandType = adCmdStoredProc
.Prepared = True
End With
'Executa a procedure
Set ors = New ADODB.Recordset
Set ors = ocmd.Execute


Thank You In Advance
mutley is offline   Reply With Quote
Old May 29th, 2000, 09:22 PM   #2
Mongo
Hyperactive Member
 
Join Date: Nov 99
Location: Leavenworth KS USA
Posts: 482
Mongo is an unknown quantity at this point (<10)
I play in a different RDBMS, so the params ordinals may be off by one, each, i.e., this is a quick SWAG, but it may help. Try replacing this in your VB code:
Code:
.
.
.
With ocmd 
  .ActiveConnection = SQLSERVER.ConnectionString 
  '  sp1
  'cmd.CommandText = "meuteste"
  'cmd.Name = "meuteste" 

  '   sp2 with params
  .CommandText = "sp2_filtramain"
  .CommandType = adCmdStoredProc
  .Parameters.Refresh
  .Parameters(0).Value = Format(cdata, "yyyy-mm-dd")
  .Parameters(1).Value = "ABDS"
End With
.
.
.
Mongo is offline   Reply With Quote
Old May 30th, 2000, 01:36 AM   #3
mutley
Fanatic Member
 
mutley's Avatar
 
Join Date: Apr 00
Location: Sao Paulo - Brazil
Posts: 560
mutley is an unknown quantity at this point (<10)
Thumbs down

Hi



I tried , but do not work
mutley is offline   Reply With Quote
Old May 30th, 2000, 02:32 AM   #4
Mongo
Hyperactive Member
 
Join Date: Nov 99
Location: Leavenworth KS USA
Posts: 482
Mongo is an unknown quantity at this point (<10)
With the same run-time errors?
Mongo is offline   Reply With Quote
Old May 30th, 2000, 07:47 AM   #5
Marcelo Velasquez
Lively Member
 
Join Date: Jan 00
Location: Sao Paulo - SP - BRAZIL
Posts: 65
Marcelo Velasquez is an unknown quantity at this point (<10)
Unhappy

Hi

The same erros, Do I believe that it is because of the Cursor, or doesn't It have anything there to be?


thank you in advance
__________________
The blessing of God enriches and it doesn't increase pains
Marcelo Velasquez is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Database Development


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 On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:04 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.