Solved

System.Web.UI.HtmlControls.HtmlInputText

Posted on 2010-08-27
2
410 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
Comment Utility
Hi,

try name.Value instead
0
 
LVL 3

Expert Comment

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

0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 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

14 Experts available now in Live!

Get 1:1 Help Now