[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

System.Web.UI.HtmlControls.HtmlInputText

Posted on 2010-08-27
2
Medium Priority
?
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
roxviper earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

649 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