Précédent   Forum du club des développeurs et IT Pro > Dotnet > Développement Web avec .NET
Développement Web avec .NET Forum d'entraide sur les technologies Web de Microsoft (ASP.NET, MVC, Ajax, Silverlight, Services web, Azure, Sharepoint, etc.).
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 20/12/2012, 14h49   #1
kryptong
Membre du Club
 
Femme
Étudiant
Inscription : janvier 2012
Messages : 160
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : janvier 2012
Messages : 160
Points : 43
Points : 43
Par défaut Le textBox n'existe pas

Bonjour tout le monde,
j'ai fait une petite application web avec VS 2012 et en essayant de connecter cette application à une base de donnée pour y entrer des données je reçois une erreur qui me dit que le TextBox_Titre n'existe pas dans ce contexte, mais pourtant il existe , voici mon bout de code:

Default.aspx
Code :
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
59
60
61
62
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"  Theme="MonApparence" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
 
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
</script>
 
<html >
<head id="Head1" runat="server">
    <title>Gestion des thèmes avec ASP.NET 2.0 et C#</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="centre">
    <table width="350px">
    <tr>
        <td colspan="2">
            <asp:Image ID="Image_Fleche" SkinID="Fleche" runat="server" />&nbsp;
            <asp:Label ID="Label_Title" SkinID="Title" runat="server" Text="Formulaire d'ajout d'un nouveau livre"></asp:Label>
        </td>
    </tr>
    <tr>
        <td style="width: 100px;"><asp:Label ID="Label_Titre" runat="server" Text="Titre "></asp:Label></td>
        <td style="width: 250px;"><asp:TextBox ID="TextBox_Titre" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td><asp:Label ID="Label_Auteur" runat="server" Text="Auteur "></asp:Label></td>
        <td><asp:TextBox ID="TextBox_Auteur" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td><asp:Label ID="Label_Catégorie" runat="server" Text="Catégorie "></asp:Label></td>
        <td><asp:TextBox ID="TextBox_Catégorie" runat="server"></asp:TextBox></td>
    </tr>
        <tr>
        <td><asp:Label ID="Label_Collection" runat="server" Text="Collection "></asp:Label></td>
        <td><asp:TextBox ID="TextBox_Collection" runat="server"></asp:TextBox></td>
    </tr>
        <tr>
        <td><asp:Label ID="Label_Langue" runat="server" Text="Langue"></asp:Label></td>
        <td><asp:TextBox ID="TextBox_Langue" runat="server"></asp:TextBox></td>
    </tr>
        <tr>
        <td><asp:Label ID="Label_Editeur" runat="server" Text="Editeur"></asp:Label></td>
        <td><asp:TextBox ID="TextBox_Editeur" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td colspan="2" style="text-align: center;">
            <br />
            <asp:Button ID="Button_Valider" runat="server" Text="Valider" OnClick="Button_Valider_Click" Width="60px" />&nbsp;
                        <asp:Button ID="Button_Annuler" runat="server" Text="Annuler" OnClick="Button_Annuler_Click" />&nbsp;
            &nbsp;
            </td>
    </tr>
    </table>
    </div>
    </form>
</body>
</html>
Default.aspx.cs
Code :
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
 
namespace WebApplication1
{
    public partial class _default  :System.Web.UI.Page
    {
        OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\USER\Documents\Visual Studio 2012\Projects\WebApplication1\livre.accdb");
        protected void Page_Load(object sender, EventArgs e)
        {
            con.Open();
 
        }
 
 
        protected void Button_Valider_Click(object sender, EventArgs e)
        {
            string vaq1 = string.Format("insert into livre values((0)",TextBox_Titre);
        }
 
 
 
 
    }
 
 
}
kryptong est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/12/2012, 15h40   #2
youtpout978
Membre Expert
 
Homme John Doe
Développeur .NET
Inscription : novembre 2010
Messages : 907
Détails du profil
Informations personnelles :
Nom : Homme John Doe
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur .NET

Informations forums :
Inscription : novembre 2010
Messages : 907
Points : 1 449
Points : 1 449
Et en faisant ça?
Code :
string vaq1 = string.Format("insert into livre values((0)",TextBox_Titre.Text);
Au passage ton code est vraiment pas propre, tu as de joli tuto sur ce site pour tout ce qui est accès base de donnée.
youtpout978 est actuellement connecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/12/2012, 15h51   #3
DotNetMatt
Membre Expert
 
Avatar de DotNetMatt
 
Homme Mathieu
Conseil - Consultant en systèmes d'information
Inscription : février 2010
Messages : 977
Détails du profil
Informations personnelles :
Nom : Homme Mathieu
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : février 2010
Messages : 977
Points : 2 005
Points : 2 005
De toute évidence ce que tu cherches à faire serait plutôt du genre :

Code C# :
1
2
3
4
protected void Button_Valider_Click(object sender, EventArgs e)
{
    string vaq1 = string.Format("insert into livre values '{0}'", TextBox_Titre.Text);
}
DotNetMatt est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/12/2012, 16h28   #4
kryptong
Membre du Club
 
Femme
Étudiant
Inscription : janvier 2012
Messages : 160
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : janvier 2012
Messages : 160
Points : 43
Points : 43
Citation:
Envoyé par Matt07 Voir le message
De toute évidence ce que tu cherches à faire serait plutôt du genre :

Code C# :
1
2
3
4
protected void Button_Valider_Click(object sender, EventArgs e)
{
    string vaq1 = string.Format("insert into livre values '{0}'", TextBox_Titre.Text);
}
ça marche pas
kryptong est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/12/2012, 17h43   #5
kryptong
Membre du Club
 
Femme
Étudiant
Inscription : janvier 2012
Messages : 160
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : janvier 2012
Messages : 160
Points : 43
Points : 43
Autre suggestion ?
kryptong est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/02/2013, 10h40   #6
kryptong
Membre du Club
 
Femme
Étudiant
Inscription : janvier 2012
Messages : 160
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : janvier 2012
Messages : 160
Points : 43
Points : 43
Bon finalement ce que j'ai fais , c'est ajouter une autre page .cs autre que celle par défaut , et ça a marché je ne sais pas pourquoi lorsque j'utilise la page Default ça marche pas .Mais l'important c'est que c'est résolu
kryptong est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 09h21.


 
 
 
 
Partenaires

Hébergement Web