.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Failed to convert parameter value from a String to a Int32.

Posted By: Rama Krishna     Posted Date: March 16, 2013    Points:5   Category :C#
while inserting through Stored Procedure ....getting error at below line

cmd.Parameters.Add("@CommendationDate", SqlDbType.DateTime).Value = Convert.ToInt32(wtxtDate.Text);

datetime is my datatype...

i want to insert ..selected date into my table..

any help?

Responses
Author: Deco             
Posted Date: March 17, 2013     Points: 20   

You cannot explicitly convert a Date to integer. Please cast it to date

cmd.Parameters.Add("@CommendationDate", SqlDbType.DateTime).Value = Convert.ToDateTime(wtxtDate.Text);

This would work :-;

Regards,
Deco
Author: Clintonzz             
Posted Date: December 10, 2013     Points: 20   

I only got the ways to convert data types in gridview control. Hope also helps.
http://www.kettic.com/winforms_ui/csharp_guide/gridview_column_convert_data_types.shtml



Sample codes here:
private void ConvertDataTypes_Load(object sender, EventArgs e)
{
GridCheckBoxColumn checkBox = new GridCheckBoxColumn("Organic", "IsOrganic");
checkBox.DataTypeConverter = new ToggleStateConverter();
this.ketticGrid.Columns.Add(checkBox);
}


Author: bhupathy2807             
Posted Date: January 30, 2014     Points: 20   

Hi,

you have to give .
Convert.ToDateTime(wtxtDate.Text);


Thanks,

Bhupathy.T




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend