stored procedure + vb.net sqlreader problem

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

I got 2 sql statment to check whether the account code exsist in one of
their tables. and then want to get the counter.
Thanks a lot.
-----my vb.net syntax-----
cmdSearch.Parameters.Add(New SqlParameter("@acctcode",
SqlDbType.VarChar, 20)).Value = Me.txtAcctCode.Text.Trim
cmdSearch.Parameters.Add(New SqlParameter("@countno",
SqlDbType.Int))
cmdSearch.Parameters("@countno").Direction =
ParameterDirection.Output

Try
Dim drCntrId As SqlDataReader =
cmdSearch.ExecuteReader(CommandBehavior.SingleRow)
While drCntrId.Read
intCount = drCntrId.Item("countno") <-- It seems do nothing
and I can get the countno
End While


DECLARE @countno_gljn as int
DECLARE @countno_arinv as int


/*GLJNHEADER*/
select @countno_gljn = count(VD.acctcode)
from gljnheader vh,gljndetail vd
where vh.voucherno = vd.voucherno and vh.validsw = 1 and rtrim(vd.acctcode)
= rtrim(@acctcode)

/*ARINVHEADER*/

select @countno_arinv = count(VD.acctcode)
from arinvinfo vh,arinvchg vd
where vh.invno = vd.invno and vh.validsw = 1 and rtrim(vd.acctcode) =
rtrim(@acctcode)

SELECT @countno = @countno_gljn + @countno_arinv

RETURN @countno
go
 
I solve my problem by....

cmdSearch.ExecuteNonQuery()
If IsDBNull(cmdSearch.Parameters.Item("@countno").Value()) Then
intCount = 0
Else
intCount = (cmdSearch.Parameters.Item("@countno").Value())
End If
cmdSearch.Dispose()
Sorry for my nevrous.
 
Back
Top