Friday, May 23, 2008

Let's Talk about .. Visual Stuido 2005-Function Get DataTable or variable from SQL2005 Stored Procedure

[VB.Net]
Public Shared Function GetDataTableByValueAAndValueB(ByVal ValueA As String, ByVal ValueB As String) As DataTable
Dim ds As New DataSet
Dim SqlParam As SqlParameter() = Nothing
addParameter(SqlParam, "@ValueA ", ValueA)
addParameter(SqlParam, "@ValueB", ValueB)
Helper.SqlHelper.FillDataset(ConnectionString _
, CommandType.StoredProcedure _
, "spPBG_Trn_TrackingList_GetDataTableByValueAAndValueB" _
, ds _
, dtName _
, SqlParam)
Return ds.Tables(dtName(0))
End Function


[VB.Net]
Public Shared Function GetResultByValueAAndValueBAndValueC(ByVal ValueA As String, ByVal ValueB As String, ByVal ValueC As String) As Integer
Dim SqlParam As SqlParameter() = Nothing
addParameter(SqlParam, "@ValueA", ValueA)
addParameter(SqlParam, "@ValueB", ValueB)
addParameter(SqlParam, "@ValueC",ValueC )

Dim dr As SqlDataReader = Helper.SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, "GetResultByValueAAndValueBAndValueC", SqlParam)
If dr.Read() Then
Result = (Helper.ConvertHelper.NullToNothing(dr("Result")))
End If

Return Result
End Function

No comments: