Cast as an integer

Results 1 to 3 of 3

Thread: Cast as an integer

  1. #1
    Join Date
    Dec 1969

    Default Cast as an integer

    My users are entering numeric data into a form and saving the results in a Int field in Sql Server. How do I cast the value entered into the textbox &#039;txtVotes_For&#039; from a text field into a Int field when I insert the value into my dbase on this line?<BR><BR>cmdInsert.Parameters.Add("@Votes_For" , txtVotes_For.text)<BR><BR>I&#039;ve tried this but it results in an overflow error:<BR>cmdInsert.Parameters.Add("@Votes_For", Cint(txtVotes_For.text))<BR><BR>Code:<BR><BR>Sub doUpdate(Source as Object, E as EventArgs)<BR> Dim con As SqlConnection<BR> Dim strInsert As String<BR> Dim cmdInsert As SqlCommand<BR><BR> con = New SqlConnection("server=x; database=ProposalsSQL; uid=; pwd=")<BR> strInsert = "sp_AddProposal"<BR> cmdInsert = New SqlCommand(strInsert, con)<BR> cmdInsert.CommandType = CommandType.StoredProcedure<BR> <BR> cmdInsert.Parameters.Add("@Votes_For", txtVotes_For.text)<BR><BR> con.Open()<BR> <BR> .....<BR> <BR>End Sub<BR><BR>&#060;asp:textbox id="txtVotes_For" Columns="20" runat="server" /&#062;<BR><BR>Thanks.<BR>

  2. #2
    Join Date
    Dec 1969
    Indianapolis, IN

    Default RE: Cast as an integer

    What is the value at that point? Seems like it&#039;s too large for an integer, hence the overflow error.

  3. #3
    Join Date
    Dec 1969

    Default Where are your parameter definitions?

    C# syntax towards bottom of article<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts