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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pollock_dCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.