Authentification utilisateurs avec ma base sql server
Bonjour ,
j'ai une base sql avec mon projet asp.net et je desire identifier les utilsateurs mais il se trouve que ma base a l'air de pas s'ouvrir voila mon code je vois pas trop ou j'ai pu faire une erreur ,votre aide me sera precieuse ...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Private Function Authentifier(ByVal strUser As String, ByVal strPassword As String) As Boolean
Dim boo As Boolean = False
strPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword, "MD5")
Dim Ocnx As SqlConnection
Ocnx = New SqlConnection()
Ocnx.ConnectionString = "Data source=Monchemin;Initial catalog=Nombase;integrated security=true"
Dim OCommand As SqlCommand = New SqlCommand("Select * from utilisateurs where Nom=' " + strUser + "'", Ocnx)
Try
Ocnx.Open()
Dim DR As SqlDataReader = OCommand.ExecuteReader()
While DR.Read
If ((DR.Item(1).ToString = strPassword)) Then
boo = True
End If
End While
Catch ex As Exception
boo = False
MsgBox("echec connexion")
End Try
Ocnx.Close()
Return boo
End Function |