Problems with Parameters with an Insert Statement...

M

Manuel Canas

Hi there,

This is the Code ;
cnSQL = New SqlConnection(ConnectionString)
cmSQL = New SqlCommand(strSQL, cnSQL)

strSQL = "INSERT tb_product VALUES(@ServiceCode,@ServiceName,@Price)"

cmSQL = New SqlCommand(strSQL, cnSQL)

Dim m As New SqlParameter("@Price", txtPrice.Text)

m.DbType = System.Data.SqlDbType.Money

cmSQL.Parameters.Add(m)

Dim s As New SqlParameter("@ServiceCode", txtServiceCode.Text)

m.DbType = System.Data.SqlDbType.Char

cmSQL.Parameters.Add(s)

Dim n As New SqlParameter("@ServiceName", txtServiceName.Text)

m.DbType = System.Data.SqlDbType.Char

cmSQL.Parameters.Add(n)

cnSQL.Open()

cmSQL.ExecuteNonQuery()

When I execute it, it throws an error saying "String was not recognized as
a valid boolean"

Any body out there that can tell what am I doing wrong here.



Thanks very much,

Manny
 
C

Cor Ligthert

Hi Manuel,

I have sended you a link in your previous thread about this, where it is
completly described.
When I look at your code you did not even look at it, I see it in my
newsreader that it is there is there somehting wrong with your newsreader?

Basicly there are two simple errors

cnSQL = New SqlConnection(ConnectionString)
strSQL = "INSERT INTO tb_product (ServiceCode, ServiceName, Price)
VALUES(@ServiceCode,@ServiceName,@Price)"
cmSQL = New SqlCommand(strSQL, cnSQL)

I did not look at the rest but at first sight that look ok, however take a
look at those pages.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top