Exécution d'une procédure stockée paramétrée SQL/Server 2005 depuis VB 2005
Bonjour,
J’ai un problème pour exécuter une procédure paramétrée SQL Server 2005 depuis VB 2005.
Tout est ok quand je lance la même procédure sans paramètre (après avoir enlevé le paramètre dans la procédure bien sûr).
Mon code côté VB est comme suit :
Code:
1 2 3 4 5 6 7 8 9 10
| Dim MyConnexion As SqlConnection = New SqlConnection("Data Source=localhost
"
Dim Mycommand As SqlCommand = MyConnexion.CreateCommand()
Mycommand.CommandType = CommandType.StoredProcedure
Mycommand.CommandText = "sp_calcul"
Mycommand.Parameters.Add("@numero", SqlDbType.NVarChar).Value = ListBox2.SelectedItem
MyConnexion.Open()
Dim MyReader As SqlDataReader = Mycommand.ExecuteReader() |
Côté Procédure stockée:
Code:
1 2 3 4 5
| procedure sp_calcul @numero nvarchar(15)
as
select *
from Table1
where TabId = @numero |
Merci d'avance pour votre aide