'------------------------------------------------------------------------ ' M A N A G E SP C L A S S ' Mangage SQL Stored Procedures ' Created 12/15/05 ' RPKessler '------------------------------------------------------------------------ 'Updated 12/18/05 'The Shared Functions Run_SP is designed to run a designated _SP from and SQL DB 'By passing the name of the _SP, the DS, DS TableName, and command text for the SP, the function 'runs the _SP and fills the DS table. 'It uses the web.config AppSettings key to get DB connectivity info. This key is not encrypted but will 'be in VS 2005. Imports System.Data Imports System.Data.SqlClient Public Class ManageSP Public Shared Function Run_SP(ByRef DS As DataSet, ByVal SP_Name As String, ByVal CmdText As String, ByVal TableName As String) As Boolean '---this sub takes a DS, name of a stored proc, the CommandText for that SP and the DS TableName to use ' and runs the _SP Try Dim ConnectionString As String ConnectionString = ConfigurationSettings.AppSettings("ConnectionString") '---create new adapter and pass it the name of the _SP and connection info Dim DA As New SqlDataAdapter(SP_Name, ConnectionString) '---now add parameters/capabilites to the DA and tell it the command to run is a _SP DA.SelectCommand.CommandType = CommandType.StoredProcedure '---name of the _SP DA.SelectCommand.CommandText = (CmdText) DA.Fill(DS, TableName) Return True Catch ex As Exception Return False End Try End Function End Class