0

i am trying to do something like this but it gives me error that cannot convert int to string , even the field which i am accessing from db is int and i parsed it into int but why ? here is my code:

userId = (int)com.Parameters["@ReturnValueUserId"].Value;
Response.Write(userId);
SqlDataSource1.InsertParameters["@userId"] = userId;

actually i am trying to insert userId into INSERTCOMMAND of sqldatasource control on .aspx page .

InsertCommand="INSERT INTO [tblJobAdv] ([advtitle], [startingdate], [endingdate], [mediumofadv], [refid], [jbid], [advDetails], [userId]) VALUES (@advtitle, @startingdate, @endingdate, @mediumofadv, @refid, @jbid, @advDetails, @userId)" 


<InsertParameters>
                <asp:Parameter Name="advtitle" Type="String" />
                <asp:Parameter DbType="Date" Name="startingdate" />
                <asp:Parameter DbType="Date" Name="endingdate" />
                <asp:Parameter Name="mediumofadv" Type="String" />
                <asp:Parameter Name="refid" Type="Int32" />          
                <asp:QueryStringParameter Name="jbid" QueryStringField="jbid" Type="Int32" />
                <asp:Parameter Name="advDetails" Type="String" />



</InsertParameters>

when i use .toString() with userid that been assigned , then it works , after changing Db field from int to Varchar but i want it to accept int variable, why it isn't accepting, send 8 hours but no progres, :( help
using sql server 2008 + asp.net3.5 (c#)

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by roopeshpm
1

use Convert.ToInt32("your value which you want to convert from string to int.");

hope it will work

thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.