Error converting data type varchar to numeric - stored procedures

L

luna

got so far then it broke and i cant get it working again - it was updating
fine but not inserting and now im getting a "Error converting data type
varchar to numeric" which i didnt have before....

stored procedure is

CREATE Procedure newupdate

@newid varchar(50),
@newnews varchar(50)

AS

IF EXISTS (SELECT * FROM dbo.news WHERE ID =@newid)

UPDATE dbo.news SET news = @newnews WHERE Id =@newid

ELSE

INSERT into dbo.news (news) VALUES ("@newnews")
GO

which parses fine - so im guessing its the asp side of things

which is

Dim newid As String = TextBox1.Text.ToString
Dim newnews As String = TextBox2.Text.ToString

Dim strConn As String = "server=;uid=sa;pwd=;database=news"
Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
Dim sql As String = "newupdate '" & newnews & "', '" & newid &
"'"

Dim Cmd As New System.Data.SqlClient.SqlCommand(sql, conn)
Dim objDR As System.Data.SqlClient.SqlDataReader
conn.Open()
objDR =
Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
'Cmd.ExecuteNonQuery()

conn.Close()

to me this should work!!!!
 
K

Kevin Spencer

Apparently the "Id" column in your database is not a varchar field...

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top