Ayuda con SQL y ASP
Publicado por José (3 intervenciones) el 26/04/2009 04:34:51
Hola,alguien podría ayudarme?Mi problema es el siguiente:
Quiero autentificarme en asp mediante un usuario SQL, Pero con esta cadena de conexion(conexion = "DATA SOURCE=" & servidor & " ; USER ID = " & usuario & "; PASSWORD =" & password & " Integrated Security = Yes;Initial Catalog=´BASE") me marca este error:
Error: Login failed for user 'a'., en .Net SqlClient Data ProviderError: Login failed for user 'a'., en .Net SqlClient Data Provider.
y con esta cadena de conexion(conexion = "Data Source=.; Initial Catalog=Proyecto;Integrated Security=True") lo unico que autentifica es el Servidor,puesto que cualquier usuario este o no registrado lo deja accesar a la pagina para usuarios registrados en sql. Les agradezco mucho su atención presta esperando que me puedan ayudar.Saludos. Aqui dejo el codigo completo para ver si me pueden ayudar por favor.
Public Sub creaConexion(ByVal usuario As String, ByVal password As String, ByVal servidor As String)
conexion = "DATA SOURCE=" & servidor & " ; USER ID = " & usuario & "; PASSWORD =" & password & " Integrated Security = Yes;Initial Catalog=´Proyecto"
'conexion = "Data Source=.; Initial Catalog=Proyecto;Integrated Security=True"
End Sub
Public Sub Pruebaconexion(ByRef pError As String)
pError = "False"
'Dim strConexion As String = conexion
Dim oConn As New SqlConnection
oConn.ConnectionString = conexion
Try
oConn.Open()
Catch ex As SqlException
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
Catch ex As Exception
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
End Try
oConn.Close()
End Sub
Public Sub EjecutaAcciones(ByVal pAccion As String, ByRef pError As String)
pError = "False"
'Dim strConexion As String = conexion
Dim oConn As New SqlConnection
'oConn.ConnectionString = strConexion
Try
oConn.Open()
Catch ex As SqlException
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
Catch ex As Exception
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
End Try
Dim oCmd As New SqlCommand
oCmd.CommandType = Data.CommandType.Text
oCmd.CommandText = pAccion
oCmd.Connection = oConn
Try
oCmd.ExecuteNonQuery()
Catch ex As SqlException
pError = "Error: " & ex.Message & ", en " & ex.Source
Catch ex As Exception
pError = "Error: " & ex.Message & ", en " & ex.Source
Finally
oConn.Close()
End Try
End Sub
Public Function EjecutaConsulta(ByVal pConsulta As String, ByRef pError As String) As Data.DataSet
pError = "False"
'Dim strConexion As String = conexion
Dim oConn As New SqlConnection
'oConn.ConnectionString = strConexion
Dim oCmd As New SqlCommand
oCmd.CommandType = Data.CommandType.Text
oCmd.CommandText = pConsulta
oCmd.Connection = oConn
Dim dsDatos As New Data.DataSet
Dim daDatos As New SqlDataAdapter
daDatos.SelectCommand = oCmd
Try
daDatos.Fill(dsDatos)
Catch Ex As SqlException
pError = "Error: " & Ex.Message & ", en " & Ex.Source
Catch Ex As Exception
pError = "Error: " & Ex.Message & ", en " & Ex.Source
Finally
daDatos.Dispose()
End Try
Return dsDatos
End Function
End Module
Quiero autentificarme en asp mediante un usuario SQL, Pero con esta cadena de conexion(conexion = "DATA SOURCE=" & servidor & " ; USER ID = " & usuario & "; PASSWORD =" & password & " Integrated Security = Yes;Initial Catalog=´BASE") me marca este error:
Error: Login failed for user 'a'., en .Net SqlClient Data ProviderError: Login failed for user 'a'., en .Net SqlClient Data Provider.
y con esta cadena de conexion(conexion = "Data Source=.; Initial Catalog=Proyecto;Integrated Security=True") lo unico que autentifica es el Servidor,puesto que cualquier usuario este o no registrado lo deja accesar a la pagina para usuarios registrados en sql. Les agradezco mucho su atención presta esperando que me puedan ayudar.Saludos. Aqui dejo el codigo completo para ver si me pueden ayudar por favor.
Public Sub creaConexion(ByVal usuario As String, ByVal password As String, ByVal servidor As String)
conexion = "DATA SOURCE=" & servidor & " ; USER ID = " & usuario & "; PASSWORD =" & password & " Integrated Security = Yes;Initial Catalog=´Proyecto"
'conexion = "Data Source=.; Initial Catalog=Proyecto;Integrated Security=True"
End Sub
Public Sub Pruebaconexion(ByRef pError As String)
pError = "False"
'Dim strConexion As String = conexion
Dim oConn As New SqlConnection
oConn.ConnectionString = conexion
Try
oConn.Open()
Catch ex As SqlException
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
Catch ex As Exception
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
End Try
oConn.Close()
End Sub
Public Sub EjecutaAcciones(ByVal pAccion As String, ByRef pError As String)
pError = "False"
'Dim strConexion As String = conexion
Dim oConn As New SqlConnection
'oConn.ConnectionString = strConexion
Try
oConn.Open()
Catch ex As SqlException
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
Catch ex As Exception
pError = "Error: " & ex.Message & ", en " & ex.Source
Exit Sub
End Try
Dim oCmd As New SqlCommand
oCmd.CommandType = Data.CommandType.Text
oCmd.CommandText = pAccion
oCmd.Connection = oConn
Try
oCmd.ExecuteNonQuery()
Catch ex As SqlException
pError = "Error: " & ex.Message & ", en " & ex.Source
Catch ex As Exception
pError = "Error: " & ex.Message & ", en " & ex.Source
Finally
oConn.Close()
End Try
End Sub
Public Function EjecutaConsulta(ByVal pConsulta As String, ByRef pError As String) As Data.DataSet
pError = "False"
'Dim strConexion As String = conexion
Dim oConn As New SqlConnection
'oConn.ConnectionString = strConexion
Dim oCmd As New SqlCommand
oCmd.CommandType = Data.CommandType.Text
oCmd.CommandText = pConsulta
oCmd.Connection = oConn
Dim dsDatos As New Data.DataSet
Dim daDatos As New SqlDataAdapter
daDatos.SelectCommand = oCmd
Try
daDatos.Fill(dsDatos)
Catch Ex As SqlException
pError = "Error: " & Ex.Message & ", en " & Ex.Source
Catch Ex As Exception
pError = "Error: " & Ex.Message & ", en " & Ex.Source
Finally
daDatos.Dispose()
End Try
Return dsDatos
End Function
End Module
Valora esta pregunta


0