Procédure stockee

rewstyle Messages postés 10 Date d'inscription mercredi 27 avril 2011 Statut Membre Dernière intervention 6 mai 2011 - 4 mai 2011 à 01:39
rewstyle Messages postés 10 Date d'inscription mercredi 27 avril 2011 Statut Membre Dernière intervention 6 mai 2011 - 4 mai 2011 à 10:03
Bonjour a tout le monde et merci d'apporter un tout petit peu d'importance a ce sujet.
Voici ma question je dois appeler une procédure stockée sous VB net qui permet d'insérer un enregistrement dans une table d'une base de donnée sql-serveur.
voici le code que j'ai écris
"Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Partial Class Habitation
Inherits System.Web.UI.Page
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim Msg As String



Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim con As String = ConfigurationManager.ConnectionStrings("GeststockConnectionString").ConnectionString
Dim cntest As New SqlConnection(con)
Dim cmd As New SqlCommand("ajouhabit", cntest)
cmd.CommandType = SqlDataSourceCommandType.StoredProcedure
cmd.CommandText = "ajouthabit"
Dim cod As New SqlParameter()
cod.ParameterName = "@cod_habit"
cod.SqlDbType = SqlDbType.Char
cod.Size = 3
cod.Direction = ParameterDirection.Input
cod.SourceVersion = DataRowVersion.Proposed
cod.Value = code_habit.Text
cmd.Parameters.Add(cod)
Dim type As New SqlParameter()
type.ParameterName = "@typ_habit"
type.SqlDbType = SqlDbType.VarChar
type.Size = 30
type.Value = type_habit.Text
cmd.Parameters.Add(type)
Dim centre As New SqlParameter()
centre.ParameterName = "@nom_ctr"
centre.SqlDbType = SqlDbType.VarChar
centre.Size = 30
centre.Value = nom_centre.Text
cmd.Parameters.Add(centre)
cntest.Open()
cmd.ExecuteNonQuery()
Msg = "apération effectuée avec succés"
Catch ex As Exception
Msg = ex.Message

End Try
message.Text = Msg
End Sub

End Class"
mais a chaque fois que je click je le bouton enregistrer j'ai ce message d'erreur "Procedure or function 'ajouthabit' expects parameter '@cod_habit', which was not supplied."
et je ne sais vraiment pas ou ca cloche??
aidez moi s'il vous plait
merci

4 réponses

cs_jopop Messages postés 1540 Date d'inscription lundi 26 mai 2003 Statut Membre Dernière intervention 1 août 2013 12
4 mai 2011 à 08:50
Salut,

quel est le type du parametre @cod_habit dans ta procédure stockée (côté SGBD) ?
0
rewstyle Messages postés 10 Date d'inscription mercredi 27 avril 2011 Statut Membre Dernière intervention 6 mai 2011
4 mai 2011 à 08:58
bonjour jopop
Tous mes paramètres sont des paramètres d'entrée
0
cs_jopop Messages postés 1540 Date d'inscription lundi 26 mai 2003 Statut Membre Dernière intervention 1 août 2013 12
4 mai 2011 à 09:09
par "quel type" j'entends varchar, byte, int ...
par "côté BDD" j'entends dans le PL/SQL de ta procédure stockée
0
rewstyle Messages postés 10 Date d'inscription mercredi 27 avril 2011 Statut Membre Dernière intervention 6 mai 2011
4 mai 2011 à 10:03
c'est un char de dimension 3
0
Rejoignez-nous