-----------------------------
Create procedure in Oracle:
-----------------------------
create or replace PROCEDURE SP_GET_UserCOUNT (returnval out number) AS
BEGIN
select count(*) into returnval from (select * from usertable);
END SP_GET_UserCOUNT;
-----------------------------
Call form you vb function
-----------------------------
#Region "getUserCount"
Public Shared Function getUserCount() As Integer
Dim returncount As Integer
Try
'Using conn As OracleConnection = New OracleConnection(connecitonstring)
Using conn As OracleConnection = New OracleConnection(My.Settings.sConnectionString)
conn.Open()
Dim cmdTyProcessTbl As OracleCommand = New OracleCommand("", conn)
cmdTyProcessTbl.CommandText = "SP_GET_UserCOUNT"
cmdTyProcessTbl.CommandType = Data.CommandType.StoredProcedure
Dim prm As OracleParameter = New OracleParameter("a", OracleDbType.Int32)
prm.Direction = Data.ParameterDirection.Output
cmdTyProcessTbl.Parameters.Add(prm)
cmdTyProcessTbl.ExecuteNonQuery()
cmdTyProcessTbl.Dispose()
returncount = prm.Value.ToString
conn.Close()
conn.Dispose()
GC.Collect()
End Using
Return Convert.ToInt32(returncount)
Catch ex As Exception
Throw ex
End Try
End Function
#End Region
Wednesday, July 1, 2009
Subscribe to:
Posts (Atom)