Solved

System.Web.UI.HtmlControls.HtmlInputText

Posted on 2010-08-27
2
412 Views
Last Modified: 2012-05-10
I have the following ASP.NET contact page.
The backend is MySql.

When I click submit and look at the data in MySql, it's not what I entered.
Here is what I get:

name: System.Web.UI.HtmlControls.HtmlInputText
email: System.Web.UI.HtmlControls.HtmlInputText
message: System.Web.UI.HtmlControls.HtmlInputText

Please help
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;

public partial class contact : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void image_Click(object sender, EventArgs e)
    {
        MySqlConnection connection = new MySqlConnection("Network Address=localhost;" +
                                                "Initial Catalog='fabrics';" +
                                                "Persist Security Info=no;" +
                                                "User Name='root';" +
                                                "Password='oap'");


        string cmdText = "INSERT INTO tblProducts(name ,email ,message)";
        cmdText += "VALUES(?name ,?email ,?message);";

        MySqlCommand cmd = new MySqlCommand(cmdText, connection);

        cmd.CommandType = CommandType.Text;

        cmd.Parameters.Add("?name", MySqlDbType.VarChar).Value = name.ToString();

        cmd.Parameters.Add("?email", MySqlDbType.VarChar).Value = name.ToString();

        cmd.Parameters.Add("?message", MySqlDbType.VarChar).Value = name.ToString();

        connection.Open();
        try
        {

            int result = cmd.ExecuteNonQuery();

            lblError.Text = "Data Saved";
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
}

Open in new window

0
Comment
Question by:Isaac
2 Comments
 
LVL 5

Accepted Solution

by:
roxviper earned 500 total points
ID: 33540486
Hi,

try name.Value instead
0
 
LVL 3

Expert Comment

by:raaziq
ID: 33540513
u might need to specify size of the varchar while adding the parameters..

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now