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

ridlejoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
pollock_dConnect With a Mentor Commented:
Try this instead...
Dim cmd1 As New System.Data.SqlClient.SqlCommand("Insert Into users (rate) Values (@rt)", conn)
 
        cmd1.Parameters.Add("@rt", Convert.ToDecimal(request.form("TextBoxrt")))

Open in new window

0
 
ridlejoAuthor Commented:
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??
0
 
pollock_dCommented:
can you not do the same as before?
cmd1.Parameters.AddWithValue("@bl", Convert.ToByte(Request.Form("CheckBoxbl")))

Open in new window

0
 
ridlejoAuthor Commented:
Thanks that did the trick.  Then I just used an if statement for the check box.  Thanks
0
All Courses

From novice to tech pro — start learning today.