By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,159 Members | 1,880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,159 IT Pros & Developers. It's quick & easy.

Error converting data type varchar to numeric - stored procedures

P: n/a
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.Clos eConnection)
'Cmd.ExecuteNonQuery()

conn.Close()

to me this should work!!!!

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"luna" <lu**@themoon.com> wrote in message
news:8f*****************@newsfep2-gui.server.ntli.net...
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.Clos eConnection)
'Cmd.ExecuteNonQuery()

conn.Close()

to me this should work!!!!

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.