pratz09
asked on
No mapping exists from object type System.Web.UI.HtmlControls.HtmlInputText to a known managed provider native type
Hi ! I wrote following code in aspx file
<asp:Panel ID="Panel1" runat="server">
<h2>
Add New Mantle Image</h2>
<label>
Image Path</label>
<p>
<asp:TextBox ID="file" runat="server" />
<!--<input type="file" runat="server" id="File1"/> -->
<asp:Literal ID="lblmessage" runat="server"/>
</p>
<label>URL (optional)</label>
<p>
<asp:TextBox ID="url1" runat="server" />
<!-- <input type="text" runat="server" id="url" /> -->
</p>
<p>
<label>
Title of Image (optional)</label><input type="text"
runat="server" id="title" /></p>
<asp:CheckBox ID="Position" runat="server" Text="Top in the order?" Font-Bold="true" TextAlign="Left" />
<br />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Text="Published? " Font-Bold="True"
TextAlign="Left" />
<div class="clear spacer">
</div>
</asp:Panel>
<p align="center">
<asp:ImageButton ID="savebutton" runat="server" ImageUrl="assets/images/bu tton_save. gif" OnClick="SaveButton_click" />
<input type="image" src="assets/images/button_ cancel.gif " class="submit inline" onclick="history.go(-1);re turn false;" />
</p>
And following code in aspx.cs file:
try
{
m_db.OpenCommand();
m_db.Command.CommandText = "insert into mantle(title, url, image, position, published, deleted) values(@ttl, @img,@pos,@url, @publish,@del)";
m_db.Command.Parameters.Ad dWithValue ("@ttl", title);
m_db.Command.Parameters.Ad dWithValue ("@url", url);
m_db.Command.Parameters.Ad dWithValue ("@img", image);
m_db.Command.Parameters.Ad dWithValue ("@pos", position);
m_db.Command.Parameters.Ad dWithValue ("@publish ", CheckBox1.Checked ? "1" : "0");
m_db.Command.Parameters.Ad dWithValue ("@del", "0");
m_db.DBExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex.Message) ;
errorfree = false;
}
And I am getting this error while debugging:
System.ArgumentException was caught
Message=No mapping exists from object type System.Web.UI.HtmlControls .HtmlInput Text to a known managed provider native type.
Source=System.Data
StackTrace:
at System.Data.SqlClient.Meta Type.GetMe taTypeFrom Value(Type dataType, Object value, Boolean inferLen)
at System.Data.SqlClient.SqlP arameter.G etMetaType Only()
at System.Data.SqlClient.SqlP arameter.V alidate(In t32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlC ommand.Bui ldParamLis t(TdsParse r parser, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlC ommand.Bui ldExecuteS ql(Command Behavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlC ommand.Run ExecuteRea derTds(Com mandBehavi or cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlC ommand.Run ExecuteRea der(Comman dBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlC ommand.Int ernalExecu teNonQuery (DbAsyncRe sult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlC ommand.Exe cuteNonQue ry()
at NeboWeb.Utilities.Data.dat abase.DBEx ecuteNonQu ery() in c:\inetpub\wwwroot\App_Cod e\database .cs:line 81
at CMS_MantleAdd.SaveButton_E vent() in c:\inetpub\wwwroot\CMS\Man tleAdd.asp x.cs:line 94
InnerException:
<asp:Panel ID="Panel1" runat="server">
<h2>
Add New Mantle Image</h2>
<label>
Image Path</label>
<p>
<asp:TextBox ID="file" runat="server" />
<!--<input type="file" runat="server" id="File1"/> -->
<asp:Literal ID="lblmessage" runat="server"/>
</p>
<label>URL (optional)</label>
<p>
<asp:TextBox ID="url1" runat="server" />
<!-- <input type="text" runat="server" id="url" /> -->
</p>
<p>
<label>
Title of Image (optional)</label><input type="text"
runat="server" id="title" /></p>
<asp:CheckBox ID="Position" runat="server" Text="Top in the order?" Font-Bold="true" TextAlign="Left" />
<br />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Text="Published? " Font-Bold="True"
TextAlign="Left" />
<div class="clear spacer">
</div>
</asp:Panel>
<p align="center">
<asp:ImageButton ID="savebutton" runat="server" ImageUrl="assets/images/bu
<input type="image" src="assets/images/button_
</p>
And following code in aspx.cs file:
try
{
m_db.OpenCommand();
m_db.Command.CommandText = "insert into mantle(title, url, image, position, published, deleted) values(@ttl, @img,@pos,@url, @publish,@del)";
m_db.Command.Parameters.Ad
m_db.Command.Parameters.Ad
m_db.Command.Parameters.Ad
m_db.Command.Parameters.Ad
m_db.Command.Parameters.Ad
m_db.Command.Parameters.Ad
m_db.DBExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex.Message)
errorfree = false;
}
And I am getting this error while debugging:
System.ArgumentException was caught
Message=No mapping exists from object type System.Web.UI.HtmlControls
Source=System.Data
StackTrace:
at System.Data.SqlClient.Meta
at System.Data.SqlClient.SqlP
at System.Data.SqlClient.SqlP
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
at System.Data.SqlClient.SqlC
at NeboWeb.Utilities.Data.dat
at CMS_MantleAdd.SaveButton_E
InnerException:
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh Man.. Can't believe it was so silly mistake. Thanks man.
Open in new window