Salut a tous;

j'ai crée une base de donnée avec sql server a travers Visual Studio 2005
et un formulaire dans une page.aspx mais mon probelme est le suivant : quand je remplis ce formulaire rien n'est ajouté dans la table de la Bdd pourtant ya rien comme erreur affiché et voici le code de ma page :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Sql;
using System.Data.SqlClient;
 
 
public partial class contact : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void Button1_Click(object sender, EventArgs e)
    { string no,pren,emai,desti,sujet,commen;
        int teleph;
        no=TextBox1.Text;
        pren=TextBox8.Text;
        emai=TextBox7.Text;
        teleph=Int32.Parse(TextBox5.Text);
        desti = DropDownList1.SelectedItem.Text;
        sujet=TextBox4.Text;
        commen=TextBox6.Text;
 
        SqlConnection Conn = new SqlConnection();
        Conn.ConnectionString ="Data Source= mead-012;"
                                                  + "Initial Catalog=maBdd.mdf;"
                                                  + "User ID=;"
                                                  + "Password=;";
 
 
        SqlCommand cmd=new SqlCommand();
        cmd.Connection =Conn;
        cmd.CommandType=CommandType.Text;
        cmd.CommandText="INSERT INTO T_comment(Nom,Prenom,Email,Telephone,Destination,Sujet,commentaire)";
        cmd.CommandText +="VALUES('"+no+"','"+pren+"','"+emai+"','"+teleph+"','"+desti+"','"+sujet+"','"+commen+"')";
 
        try
        {
            Conn.Open();
            cmd.ExecuteNonQuery();
            Conn.Close();
 
        }
        catch (Exception )
        {
            Response.Write("erreur" );
        }
 
    }
}
Pouvez vous m'indiquez ou est le problème ou bien me corrigez le code s'il ya des erreurs.

Merci en toutes les cas de votre intention.