Bonjour,
j'ai un petit problème présentement avec ma requête SQL. Je doit lire dans ma table tblMuscular le champ Muscular_Id. Le type de donnée de ce champs est mis sur NuméroAuto. Quand j'execute ma requête SQL avec datareader. Ca ne veut pas s'executer. Ce que je comprend en ce moment c'est que je passe une commande texte. Quand je demande de lire dans le champs Muscular_Id, il voit que c'est un NuméroAuto (donc une valeur numérique entière). Tandis que c'est une commande Texte de format String, il ne l'accepte pas.
Il y a sûrement une solution à ce problème. Voici mon code:
Dim strSQL As String
Dim strLigne1 As String
Dim strLigne2 As String
Dim strImaId As String
Dim intImaId As Integer
Dim Read As New IniReader(Application.StartupPath & "\ImaCount.txt")
Dim drExercicePic As OleDbDataReader
Dim cmdSelect As OleDbCommand = New OleDbCommand
' Lie dans le fichier ImaCount.txt la valeur de l'image qui a été
' sélectionné...
intImaId = Read.Read_Value("ID", "Image" & strImageId)
Read.Close()
' Met l'image sélectionné dans le picturebox...
picDetail.Image = picDblSelect.Image
Try
' Ouvre la connection de la base de donnée...
OpenConnexion()
strSQL = "SELECT Note, Note_Cust "
strSQL &= "FROM tblMuscular "
strSQL &= "WHERE Muscular_Id = '" & intImaId & "'"
With cmdSelect
.Connection = cnExercise
.CommandType = CommandType.Text
.CommandText = strSQL
drExercicePic = .ExecuteReader()
End With
' Print on the list box all the items founds...
Do While drExercicePic.Read()
strLigne1 = drExercicePic.GetString(0)
strLigne2 &= drExercicePic.GetString(1)
Loop
' Close the datareader, the connexion to the database,
drExercicePic.Close()
CloseConnexion()
Catch ex As Exception
' Print error message if we have a problem connection with
' database...
MessageBox.Show("Try to connect to the database", _
"Error Connection", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try