Problème avec data reader
Bonjour à tous,
J'ai une variable de type Array que j'essaye de remplir avec un DataReader.
Je vais essayer de m'expliquer:
J'ai une table T_mdp (user_nom [string], user_id [int32], mdp [string])
Je voudrais mettre dans un Array les champs mdp et user_id.
voilà mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Dim MyConnexion As OleDbConnection = New OleDbConnection(ConnectionString)
Dim Mycommand As OleDbCommand = MyConnexion.CreateCommand()
strSQL = "SELECT T_mdp.mdp, T_mdp.user_id " & _
"FROM T_mdp " & _
"WHERE T_mdp.user_nom='Username'"
Mycommand.CommandText = strSQL
MyConnexion.Open()
Dim Reader As OleDbDataReader = Mycommand.ExecuteReader()
Dim arrResult(2)
For i = 1 To 2
If Reader.Read() Then
arrResult(0) = True
arrResult(i) = Reader(i - 1)
Else
If Not arrResult(0) = True Then arrResult(0) = False
End If
Next
Reader.Close()
MyConnexion.Close() |
J'arrive à remplir le mdp, mais il mets la valeur Null pour le user_id, l'Array reste donc (True, mdp, Null), et je ne compreds pas pourquoi, car le champs est bien rempli sur la table.
Est-ce que quelqu'un pourrait m'aider, svp?
Merci d'avance