mon problème est que je dois passer un array ... en paramètre dans un requête sql
Dim strJoinedString As String ' join the strings strJoinedString = Join(strStrings, ",")
Dim strStrings() As String = array.ToArray(GetType(String))et c'est ainsi que le paramètre passé est un string
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Function GetJoinStr() As String
Dim joinstr As String = String.Empty
For i = 0 To DataGridView1.Rows.Count - 2
'à la place de column1 le nom de ta colonne
joinstr &= DataGridView1.Rows(i).Cells("column1").Value & ","
Next
'on supprime la derniere virgule
joinstr = joinstr.Substring(0, joinstr.Length - 1)
Return joinstr
End Function
Dim query As String
query = "SELECT F_DOCLIGNE.AR_Ref,SUM(DL_Qte),Emplacement,F_DOCLIGNE.DL_Design,F_DOCLIGNE.CT_Num _ FROM F_DOCLIGNE "
query &= " LEFT JOIN F_ARTICLE on F_ARTICLE.cbAR_Ref=F_DOCLIGNE.cbAR_Ref "
query &= " where DO_Piece IN (@NumPiece) AND DL_Design <> 'BON URGENT' "
query &= "AND (F_Docligne.DO_Type='12') GROUP BY F_Docligne.Ar_Ref,emplacement,F_DOCLIGNE.DL_Design,F_DOCLIGNE.CT_Num"
Dim cmd As New SqlCommand(query, cnx)
cmd.Parameters.Add("@NumPiece", SqlDbType.VarChar)
cmd.Parameters("@NumPiece").Value = GetJoinStr()
cmd.ExecuteReader()
joinstr &= DataGridView1.Rows(i).Cells("column1").Value & ","il faut
joinstr &= DataGridView1.Rows(i).Cells("column1").Value.tostring & ","