asp.net 메모리 프로세스 호출

2594 단어
1. 저장 프로세스를 호출하지만 되돌아오는 값이 없습니다
 
  
Private Function SqlProc1(ByVal ProcName As String) As Boolean
' , myConn ProcName
Dim myCommand As New SqlClient.SqlCommand(ProcName, myConn)
With myCommand
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@CodeType", SqlDbType.VarChar, 20).Value = " "
Try
.ExecuteNonQuery()
Return True
Catch ex As Exception
Return False
End Try
End Function

2. 저장 프로세스를 호출하여 일반 값을 되돌려줍니다
 
  
Private Function SqlProc1(ByVal ProcName As String) As String
' , myConn
Dim myCommand As New SqlClient.SqlCommand(ProcName, myConn)
With myCommand
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@CodeType", SqlDbType.VarChar, 20).Value = " "
.Parameters.Add("@NewCode", SqlDbType.VarChar, 20).Direction = ParameterDirection.Output
Try
.ExecuteNonQuery()
Return .Parameters(1).Value()
Catch ex As Exception
Return " "
End Try
End Function

3. 저장 프로세스를 호출하여 데이터 집합을 되돌려줍니다
'VB.NET 코드
 
  
Private Function SqlProc2(ByVal ProcName As String, ByVal Param1 As String) As DataSet
' ,
Dim myCommand As New SqlClient.SqlCommand
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = ProcName
myCommand.Connection = myConn
' ,
Dim myDapter As New SqlClient.SqlDataAdapter(myCommand)
myDapter.SelectCommand.Parameters.Add("@name", SqlDbType.VarChar, 20).Value = Param1
' ,
Dim myDataSet As New DataSet
Try
myDapter.Fill(myDataSet)
Catch ex As Exception
End Try
Return myDataSet
End Function
'
Create Proc Test @name varchar(20) As
Select * From EC_Grade where cGradeName=@name
GO
*** ,
CREATE Proc Test
@name varchar(200)=''
-- 200 , ;
As
Declare @sql1 varchar(8000)
if @name<>''
Select @sql1='Select * From EC_Grade where '+ @name
else
Select @sql1='Select * From EC_Grade'
exec(@sql1)
GO

좋은 웹페이지 즐겨찾기