metodo para registrar conexion mejorado
This commit is contained in:
@@ -178,28 +178,20 @@ Public Class ClsBancos
|
||||
If TransaccionCompartida Is Nothing Then
|
||||
SqlConexion = New SqlConnection
|
||||
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
|
||||
SqlCommand = New SqlCommand("", SqlConexion)
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
Try
|
||||
SqlConexion.Open()
|
||||
ConexionAdd(HttpContext.Current.Request.Url.AbsolutePath.ToString)
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
|
||||
End Try
|
||||
Else
|
||||
SqlConexion = TransaccionCompartida.Connection
|
||||
SqlTransacc = TransaccionCompartida
|
||||
SqlCommand = New SqlCommand("", SqlConexion)
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
SqlTransacc = TransaccionCompartida
|
||||
End If
|
||||
|
||||
'SqlCommand = New SqlCommand("", SqlConexion)
|
||||
'SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
'Try
|
||||
' ConexionAdd(HttpContext.Current.Request.Url.AbsolutePath.ToString)
|
||||
'Catch ex As Exception
|
||||
SqlCommand = New SqlCommand("", SqlConexion)
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
ConexionAdd()
|
||||
|
||||
'End Try
|
||||
End Sub
|
||||
Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
|
||||
With SqlAdapter.SelectCommand
|
||||
@@ -213,19 +205,15 @@ Public Class ClsBancos
|
||||
|
||||
#Region "Conexiones"
|
||||
|
||||
Private Sub ConexionAdd(Url As String)
|
||||
Private Sub ConexionAdd()
|
||||
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
|
||||
|
||||
'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
'.Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.ToString
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = Url
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
|
||||
Try
|
||||
Try
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.ToString
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
SqlAdapter.Fill(Data)
|
||||
CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero
|
||||
Catch ex As Exception
|
||||
|
||||
@@ -55,20 +55,18 @@ Public Class ClsCompras
|
||||
If TransaccionCompartida Is Nothing Then
|
||||
SqlConexion = New SqlConnection
|
||||
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
Try
|
||||
SqlConexion.Open()
|
||||
ConexionAdd()
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
|
||||
End Try
|
||||
End Try
|
||||
Else
|
||||
SqlConexion = TransaccionCompartida.Connection
|
||||
SqlTransacc = TransaccionCompartida
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
End If
|
||||
End If
|
||||
|
||||
'SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
ConexionAdd()
|
||||
|
||||
End Sub
|
||||
|
||||
@@ -86,16 +84,13 @@ Public Class ClsCompras
|
||||
|
||||
Private Sub ConexionAdd()
|
||||
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
|
||||
|
||||
'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.ToString
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
|
||||
Try
|
||||
Try
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.ToString
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
SqlAdapter.Fill(Data)
|
||||
CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero
|
||||
Catch ex As Exception
|
||||
|
||||
@@ -81,20 +81,17 @@ Public Class ClsVentas
|
||||
If TransaccionCompartida Is Nothing Then
|
||||
SqlConexion = New SqlConnection
|
||||
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
Try
|
||||
SqlConexion.Open()
|
||||
ConexionAdd()
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
|
||||
End Try
|
||||
Else
|
||||
SqlConexion = TransaccionCompartida.Connection
|
||||
SqlTransacc = TransaccionCompartida
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
End If
|
||||
|
||||
'SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
SqlAdapter = New SqlDataAdapter("", SqlConexion)
|
||||
ConexionAdd()
|
||||
|
||||
End Sub
|
||||
Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure)
|
||||
@@ -111,16 +108,13 @@ Public Class ClsVentas
|
||||
|
||||
Private Sub ConexionAdd()
|
||||
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
|
||||
|
||||
'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.ToString
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
|
||||
Try
|
||||
Try
|
||||
DataAdapter("PA_Sis_RegistrarConexion")
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name
|
||||
.Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.ToString
|
||||
.Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
|
||||
End With
|
||||
SqlAdapter.Fill(Data)
|
||||
CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user