nsegi
Messages postés31Date d'inscriptionmardi 22 juillet 2008StatutMembreDernière intervention20 décembre 2013
-
14 oct. 2009 à 12:58
nsegi
Messages postés31Date d'inscriptionmardi 22 juillet 2008StatutMembreDernière intervention20 décembre 2013
-
14 oct. 2009 à 13:54
Bjrs a tous, je voulait recuperer la valeur dans un champs dans ma base de donnee et l'afficher dans un textbox:
j'ai ces codes:
'apres la chaine de connection bien sur...
Dim str As String = "Select produit.pronom from produit where idproduit='CH'"
Dim myCommand As SqlCommand = Nothing
Dim myReader As sqlDataReader = Nothing
Try
myCommand = New SqlCommand(str, MyConnection)
MyConnection.Open()
myReader = myCommand.ExecuteReader()
If myReader.HasRows Then
While myReader.Read
TextBox1.Text = myReader.GetString(1)
End While
Else
End If
Catch ex As Exception
MsgBox(ex.ToString())
Finally
myReader.Close()
MyConnection.Close()
End Try
mais ca donne rien . Ou changer et myReader.GetString(1) que veut dire le chifre (1) car je trouver ca sur le forum en croyant que c'est l'indice du chanpa voulut mais en vain
nsegi
Messages postés31Date d'inscriptionmardi 22 juillet 2008StatutMembreDernière intervention20 décembre 2013 14 oct. 2009 à 13:54
Bon voila apres quelques acrobaties je enfin trouver,
il faut changer le bloc if:
If myReader.HasRows Then
While myReader.Read
TextBox1.Text = myReader.GetString(1)
End While
End If
comme suit:
If myReader.HasRows Then
While myReader.Read
TextBox1.Text = myReader("pronom").ToString
End While
End If
et le tour est joué
------------------------
Sengi Jonathan