Link to home
Start Free TrialLog in
Avatar of ridlejo
ridlejoFlag for United States of America

asked on

Need to insert decimal value

I am using visual web developer 2008 and .net 3.5.  I have a simple insert statement that inserts a field value in to my table.  On my web form I have a text field called TextBoxrt. In my table this is a decimal value.  It will hold a dollar value.  When I set my form variable and attempt to insert I get Conversion from string "rt" to type 'Integer' is not valid.

Here is my insert statement and parameter
Dim cmd1 As New System.Data.SqlClient.SqlCommand("Insert Into users (rate) Values (@rt)", conn)
 
        cmd1.Parameters.Add("@rt", System.Data.SqlDbType.Decimal, "rt").Value = request.form("TextBoxrt")

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of pollock_d
pollock_d

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ridlejo

ASKER

This looks like it will work.  It should be :
cmd1.Parameters.AddWithValue("@rt", Convert.ToDecimal(request.form("TextBoxrt"))).
But now I am having the same issue with a checkbox:
        cmd1.Parameters.Add("@bl", System.Data.SqlDbType.Bit, "bl").Value = Request.Form("CheckBoxbl")
Any idea?  I can post a new question and then you could answer it quickly??
Avatar of pollock_d
pollock_d

can you not do the same as before?
cmd1.Parameters.AddWithValue("@bl", Convert.ToByte(Request.Form("CheckBoxbl")))

Open in new window

Avatar of ridlejo

ASKER

Thanks that did the trick.  Then I just used an if statement for the check box.  Thanks