Imports System.Data.SqlClient
Module EmpresasDAO



    Public Function ObtenerNombreBDSAP(ByVal pCodigoEmpresa As String) As String
        Dim objCon As New Conexion
        Dim r As String = String.Empty
        Dim query As String
        Dim cmd As SqlCommand
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        If Not String.IsNullOrEmpty(pCodigoEmpresa) Then
            query = "SELECT T0.SAP_BD FROM [dbo].[EMPR] T0 WHERE T0.CodEmpr=@CodEmpr"
            cmd = New SqlCommand
            cmd.CommandText = query

            cmd.Parameters.Add("@CodEmpr", SqlDbType.VarChar).Value = pCodigoEmpresa
            cmd.Connection = cn



            'Double.TryParse(cmd.ExecuteScalar.ToString, r)
            r = cmd.ExecuteScalar.ToString
            cn.Close()
            If String.IsNullOrEmpty(r) Then
                Return 0
            End If

        End If

        Return r
    End Function







End Module
