2 Replies - 1061 Views - Last Post: 19 September 2011 - 07:53 AM

#1 Shadar   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 157
  • Joined: 26-May 09

SQL Server Data Retrieval Made Easy

Posted 11 January 2011 - 07:36 AM

Description:
Create a module and copy this code into it.
Set your connection string in the Connection Property and call functions from your App.

Also the Connection String is hard coded here, I usually put in the App.Congig or in App Settings.

Always make sure the function called doesn't return Nothing

Note this can be easily turned into a class if necessary.
A data retrival module for SQL Server.
All you have to do is pass in SQL String or Stored Procedure Name, Command Type, and parameters (if any)

Imports System.Data
Imports System.Data.SqlClient

Public Module cm 'Connection Module
    Private m_sqlConn As System.Data.SqlClient.SqlConnection = Connection

    Public ReadOnly Property Connection() As System.Data.SqlClient.SqlConnection
        Get
            Connection = New System.Data.SqlClient.SqlConnection("Data Source=SERVERNAME;Initial Catalog=DBNAME;Integrated Security=True")
        End Get
    End Property


    Private Function unconditionalClose(ByVal sqlConnstr As IDbConnection)
        unconditionalClose = Nothing
        Try
            sqlConnstr.Close()
        Catch ex As Exception
        End Try
    End Function

    Public Function TruncateSQLTable(ByVal myTable As String) As Integer
        'Calls a stored procedure to truncate the Nominee_Temp table.
        Dim mycmd As System.Data.SqlClient.SqlCommand = CMD("Truncate Table  " & myTable, CommandType.Text)
        Dim returnValue As Integer
        Try
            mycmd.Connection = Connection
            mycmd.Connection.Open()
            returnValue = mycmd.ExecuteScalar()
            mycmd.Connection.Close()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Error Truncating Table")
            Return 1
        End Try

        Return (returnValue)
    End Function

    Public Function GetTableRowCount(ByVal TableName As String) As Integer
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD("Select Count(*) from " & TableName, CommandType.Text)
        'Dim dtGetDataTable As New DataTable
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim retval As Integer
        Try
            SpCmd.Connection.Open()
            retval = SpCmd.ExecuteScalar()
            Return retval
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return retval
    End Function

    Public Function Getdata_DS(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataSet
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim DS As New DataSet
        Try
            SpCmd.Connection.Open()
            sqladp.Fill(DS)
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return DS
    End Function

    Private Function Getdata_DA(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType) As System.Data.SqlClient.SqlDataAdapter
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType)
        Getdata_DA = Nothing
        Try
            SpCmd.Connection.Open()
            Getdata_DA = New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
    End Function

    Private Function GetDataReader(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As SqlDataReader
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        GetDataReader = Nothing
        Try
            SpCmd.Connection.Open()
            GetDataReader = SpCmd.ExecuteReader()
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        If GetDataReader.HasRows Then
            Return GetDataReader
        End If
    End Function

    Private Function DataUpdate(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Boolean
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLERROR As Boolean = False
        Dim sqlStr As String = Nothing
        Try
            SpCmd.Connection = m_sqlConn
            SpCmd.Connection.Open()
            SQLERROR = SpCmd.ExecuteScalar()
        Catch ex As Exception
            ShowException(ex)
            SQLERROR = True
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try

        Return SQLERROR
    End Function

    Public Function ExecuteNonQuery(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Boolean
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLERROR As Boolean = False
        Dim sqlStr As String = Nothing
        Try
            SpCmd.Connection.Open()
            SQLERROR = SpCmd.ExecuteNonQuery()
        Catch ex As Exception
            ShowException(ex)
            SQLERROR = True
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return SQLERROR
    End Function
    Public Function DataUpdateRetVal(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Integer
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLRetValue As Integer = Nothing
        Dim sqlStr As String = Nothing
        Try
            SpCmd.Connection.Open()
            SQLRetValue = SpCmd.ExecuteScalar()
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return SQLRetValue
    End Function

    Public Function GetDataIntRetVal(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Integer
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLRetValue As Integer = 0
        Try
            SpCmd = CMD(strSQL, CMDType)
            SpCmd.Connection.Open()
            If SpCmd.ExecuteScalar IsNot Nothing Then
                SQLRetValue = SpCmd.ExecuteScalar()
            End If
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return SQLRetValue
    End Function

    Public Function GetDataStringRetVal(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As String
        Dim SPCMD As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLRetValue As String = Nothing
        Dim sqlStr As String = Nothing
        Try
            SPCMD = CMD(strSQL, CMDType)
            SPCMD.Connection.Open()
            If SPCMD.ExecuteScalar IsNot Nothing Then
                SQLRetValue = SPCMD.ExecuteScalar().ToString
            End If
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SPCMD.Connection)
        End Try

        Return SQLRetValue
    End Function

    Public Function GetDataFieldValue_String(ByVal strSQL As String, ByVal inFieldToLookUp As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As String
        Dim dr As DataRow
        Dim strRETVAL As String = ""
        Try
            dr = GetDataRow(strSQL, CMDType)
            If Not IsNothing(dr) Then
                strRETVAL = dr.Item(inFieldToLookUp).ToString
                Return strRETVAL
            End If
            Return Nothing
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        End Try
    End Function

    Public Function GetDataRows(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataRow()
        Dim SpCmd As SqlCommand = CMD(strSQL, CMDType, PA)
        Dim dt As New DataTable
        Dim drs() As DataRow = Nothing
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        SpCmd.Connection = m_sqlConn
        Try
            If Not IsNothing(SpCmd) Then
                SpCmd.Connection.Open()
                sqladp.Fill(dt)
                drs = dt.Select
            End If
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return drs
    End Function

    Public Function GetDataRow(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataRow
        Dim SpCmd As SqlCommand = CMD(strSQL, CMDType, PA)
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim dt As New DataTable
        Dim dr As DataRow = Nothing
        Try
            If Not IsNothing(SpCmd) Then
                SpCmd.Connection.Open()
                sqladp.Fill(dt)
                If dt.Rows.Count <> 0 Then
                    dr = dt.Rows(0)
                End If
                If Not IsNothing(dr) Then
                    Return dr
                End If
            End If
            Return Nothing
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
    End Function

    Public Function GetDataTable(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataTable
        Dim SpCmd As SqlCommand = CMD(strSQL, CMDType, PA)
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim dt As New DataTable
        Try
            If Not IsNothing(SpCmd) Then
                SpCmd.Connection.Open()
                sqladp.Fill(dt)
                If Not IsNothing(dt) Then
                    Return dt
                End If
            End If
            Return Nothing
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        Finally
            Try
                unconditionalClose(SpCmd.Connection)
            Catch ex As Exception
            End Try
        End Try
    End Function

    Private Function CMD(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal inPA() As SqlParameter = Nothing) As SqlClient.SqlCommand
        Try
            Dim mySQLCmd As New System.Data.SqlClient.SqlCommand(strSQL)
            mySQLCmd.CommandType = CMDType
            mySQLCmd.Connection = Connection
            If Not inPA Is Nothing Then
                For Each item As SqlParameter In inPA
                    mySQLCmd.Parameters.Add(item)
                Next
            End If
            Return mySQLCmd
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

    Public Sub ShowException(ByVal ex As Exception)
        MessageBox.Show("Message: " & ex.Message & vbCrLf & "Error Source: " & ex.Source & vbCrLf & "Location: " & ex.TargetSite.ToString & _
        vbCrLf & "Error Stack Trace: " & ex.StackTrace, "Exception Information", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Sub
End Module

This post has been edited by AdamSpeight2008: 11 January 2015 - 08:55 PM


Is This A Good Question/Topic? 0
  • +

Replies To: SQL Server Data Retrieval Made Easy

#2 Shadar   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 157
  • Joined: 26-May 09

Re: SQL Server Data Retrieval Made Easy

Posted 11 January 2011 - 07:36 AM

Description: Create a module and copy this code into it. Set your connection string in the Connection Property and call functions from your App. Also the Connection String is hard coded here, I usually put in the App.Config or in App Settings. Always make sure the function called doesn't return Nothing Note this can be easily turned into a class if necessary.A data retrieval module for SQL Server. All you have to do is pass in SQL String or Stored Procedure Name, Command Type, and parameters (if any)
Imports System.Data
Imports System.Data.SqlClient

Public Module cm 'Connection Module
    Private m_sqlConn As System.Data.SqlClient.SqlConnection = Connection

    Public ReadOnly Property Connection() As System.Data.SqlClient.SqlConnection
        Get
            Connection = New System.Data.SqlClient.SqlConnection("Data Source=SERVERNAME;Initial Catalog=DBNAME;Integrated Security=True")
        End Get
    End Property


    Private Function unconditionalClose(ByVal sqlConnstr As IDbConnection)
        unconditionalClose = Nothing
        Try
            sqlConnstr.Close()
        Catch ex As Exception
        End Try
    End Function

    Public Function TruncateSQLTable(ByVal myTable As String) As Integer
        'Calls a stored procedure to truncate the Nominee_Temp table.
        Dim mycmd As System.Data.SqlClient.SqlCommand = CMD("Truncate Table  " & myTable, CommandType.Text)
        Dim returnValue As Integer
        Try
            mycmd.Connection = Connection
            mycmd.Connection.Open()
            returnValue = mycmd.ExecuteScalar()
            mycmd.Connection.Close()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Error Truncating Table")
            Return 1
        End Try

        Return (returnValue)
    End Function

    Public Function GetTableRowCount(ByVal TableName As String) As Integer
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD("Select Count(*) from " & TableName, CommandType.Text)
        'Dim dtGetDataTable As New DataTable
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim retval As Integer
        Try
            SpCmd.Connection.Open()
            retval = SpCmd.ExecuteScalar()
            Return retval
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return retval
    End Function

    Public Function Getdata_DS(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataSet
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim DS As New DataSet
        Try
            SpCmd.Connection.Open()
            sqladp.Fill(DS)
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return DS
    End Function

    Private Function Getdata_DA(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType) As System.Data.SqlClient.SqlDataAdapter
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType)
        Getdata_DA = Nothing
        Try
            SpCmd.Connection.Open()
            Getdata_DA = New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
    End Function

    Public Function GetDataReader(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As SqlDataReader
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        GetDataReader = Nothing
        Try
            SpCmd.Connection.Open()
            GetDataReader = SpCmd.ExecuteReader()
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        If GetDataReader.HasRows Then
            Return GetDataReader
        End If
    End Function

    Public Function DataUpdate(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Boolean
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLERROR As Boolean = False
        Dim sqlStr As String = Nothing
        Try
            SpCmd.Connection = m_sqlConn
            SpCmd.Connection.Open()
            SQLERROR = SpCmd.ExecuteScalar()
        Catch ex As Exception
            ShowException(ex)
            SQLERROR = True
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try

        Return SQLERROR
    End Function

    Public Function ExecuteNonQuery(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Boolean
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLERROR As Boolean = False
        Dim sqlStr As String = Nothing
        Try
            SpCmd.Connection.Open()
            SQLERROR = SpCmd.ExecuteNonQuery()
        Catch ex As Exception
            ShowException(ex)
            SQLERROR = True
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return SQLERROR
    End Function
    Public Function DataUpdateRetVal(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Integer
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLRetValue As Integer = Nothing
        Dim sqlStr As String = Nothing
        Try
            SpCmd.Connection.Open()
            SQLRetValue = SpCmd.ExecuteScalar()
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return SQLRetValue
    End Function

    Public Function GetDataIntRetVal(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As Integer
        Dim SpCmd As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLRetValue As Integer = 0
        Try
            SpCmd = CMD(strSQL, CMDType)
            SpCmd.Connection.Open()
            If SpCmd.ExecuteScalar IsNot Nothing Then
                SQLRetValue = SpCmd.ExecuteScalar()
            End If
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return SQLRetValue
    End Function

    Public Function GetDataStringRetVal(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As String
        Dim SPCMD As System.Data.SqlClient.SqlCommand = CMD(strSQL, CMDType, PA)
        Dim SQLRetValue As String = Nothing
        Dim sqlStr As String = Nothing
        Try
            SPCMD = CMD(strSQL, CMDType)
            SPCMD.Connection.Open()
            If SPCMD.ExecuteScalar IsNot Nothing Then
                SQLRetValue = SPCMD.ExecuteScalar().ToString
            End If
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SPCMD.Connection)
        End Try

        Return SQLRetValue
    End Function

    Public Function GetDataFieldValue_String(ByVal strSQL As String, ByVal inFieldToLookUp As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As String
        Dim dr As DataRow
        Dim strRETVAL As String = ""
        Try
            dr = GetDataRow(strSQL, CMDType)
            If Not IsNothing(dr) Then
                strRETVAL = dr.Item(inFieldToLookUp).ToString
                Return strRETVAL
            End If
            Return Nothing
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        End Try
    End Function

    Public Function GetDataRows(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataRow()
        Dim SpCmd As SqlCommand = CMD(strSQL, CMDType, PA)
        Dim dt As New DataTable
        Dim drs() As DataRow = Nothing
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        SpCmd.Connection = m_sqlConn
        Try
            If Not IsNothing(SpCmd) Then
                SpCmd.Connection.Open()
                sqladp.Fill(dt)
                drs = dt.Select
            End If
        Catch ex As Exception
            ShowException(ex)
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
        Return drs
    End Function

    Public Function GetDataRow(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataRow
        Dim SpCmd As SqlCommand = CMD(strSQL, CMDType, PA)
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim dt As New DataTable
        Dim dr As DataRow = Nothing
        Try
            If Not IsNothing(SpCmd) Then
                SpCmd.Connection.Open()
                sqladp.Fill(dt)
                If dt.Rows.Count <> 0 Then
                    dr = dt.Rows(0)
                End If
                If Not IsNothing(dr) Then
                    Return dr
                End If
            End If
            Return Nothing
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        Finally
            unconditionalClose(SpCmd.Connection)
        End Try
    End Function

    Public Function GetDataTable(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal PA() As SqlParameter = Nothing) As DataTable
        Dim SpCmd As SqlCommand = CMD(strSQL, CMDType, PA)
        Dim sqladp As New System.Data.SqlClient.SqlDataAdapter(SpCmd)
        Dim dt As New DataTable
        Try
            If Not IsNothing(SpCmd) Then
                SpCmd.Connection.Open()
                sqladp.Fill(dt)
                If Not IsNothing(dt) Then
                    Return dt
                End If
            End If
            Return Nothing
        Catch ex As Exception
            ShowException(ex)
            Return Nothing
        Finally
            Try
                unconditionalClose(SpCmd.Connection)
            Catch ex As Exception
            End Try
        End Try
    End Function

    Private Function CMD(ByVal strSQL As String, ByVal CMDType As System.Data.CommandType, Optional ByVal inPA() As SqlParameter = Nothing) As SqlClient.SqlCommand
        Try
            Dim mySQLCmd As New System.Data.SqlClient.SqlCommand(strSQL)
            mySQLCmd.CommandType = CMDType
            mySQLCmd.Connection = Connection
            If Not inPA Is Nothing Then
                For Each item As SqlParameter In inPA
                    mySQLCmd.Parameters.Add(item)
                Next
            End If
            Return mySQLCmd
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

    Public Sub ShowException(ByVal ex As Exception)
        MessageBox.Show("Message: " & ex.Message & vbCrLf & "Error Source: " & ex.Source & vbCrLf & "Location: " & ex.TargetSite.ToString & _
        vbCrLf & "Error Stack Trace: " & ex.StackTrace, "Exception Information", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Sub
End Module

Was This Post Helpful? 0
  • +
  • -

#3 Shadar   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 157
  • Joined: 26-May 09

Re: SQL Server Data Retrieval Made Easy

Posted 19 September 2011 - 07:53 AM

Example for how to pass in parameters.

'How to add and pass Parameters via SQLServer Class

' Dim inpa(0) As SqlClient.SqlParameter
'        inpa(0) = New SqlClient.SqlParameter()
'        inpa(0).Direction = ParameterDirection.Input
'        inpa(0).ParameterName = "@CustomerID"
'        inpa(0).SqlDbType = SqlDbType.NChar
'        inpa(0).Value = "VICTE"
'        'tblTest = cm_SQLSERVER.GetDataTable(strSQL, CommandType.Text, inpa)
'        tblTest = cm_SQLSERVER.GetDataTable(strSQL, CommandType.StoredProcedure, inpa)

This post has been edited by AdamSpeight2008: 11 January 2015 - 08:55 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1