SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


error - incorrect syntax near '4'


error - incorrect syntax near '4'

Author
Message
Eugene Elutin
Eugene Elutin
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5078 Visits: 5478
ssurekha2000 (10/15/2012)
no i have not created anytriggers


Can you please post exact error message you have from your application including error source (call-stack would be even better)

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
SQL Dev-938873
SQL Dev-938873
SSC-Enthusiastic
SSC-Enthusiastic (150 reputation)SSC-Enthusiastic (150 reputation)SSC-Enthusiastic (150 reputation)SSC-Enthusiastic (150 reputation)SSC-Enthusiastic (150 reputation)SSC-Enthusiastic (150 reputation)SSC-Enthusiastic (150 reputation)SSC-Enthusiastic (150 reputation)

Group: General Forum Members
Points: 150 Visits: 425
Then, may be problem with data

have u updated with my procedure.....(missing columns included in insert for trans table)


do one thing....

post rate value which u get from another table in the first statement... that row data and
post the row of data which u r trying to update in trans table if data exists

i guess.. this problem with the data

GaNeSH
ssurekha2000
ssurekha2000
SSC-Enthusiastic
SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)

Group: General Forum Members
Points: 145 Visits: 207
ya i updated the stored procedure as given by u

i even tried by hardcoding the values in sp without passing the parameters still i get the error as below

System.Data.SqlClient.Sqlexception }: {"Incorrect syntax near '4'."}

error code :-2146232060

source : ".Net SqlClient Data Provider"

stack trace : " at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at


below is thhe sp

ALTER PROCEDURE [dbo].[usp_updaterate]
--@pcid int
--,@ppid int
--,@ptid int
--,@pqty int
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Rate int
--SET @Rate = (select prate from [M_PRDT] where PID=@ppid)
IF EXISTS (SELECT cid FROM [trans] WHERE cid =36 and pid =47)--@pcid and pid=@ppid)
BEGIN
UPDATE [trans]
--set rate=@Rate
--WHERE cid =@pcid and pid=@ppid
set rate =6
where cid=36 and pid=47
END
Else
BEGIN
insert into [trans] (tid,cid,pid,qty,rate,[month],[year],amount,billno,frmdt,todt)
--select @ptid,@pcid,@ppid,@pqty,@Rate,0,0,00,'00','1/1/1900','1/1/1900'
select 215,36,47,0,6,0,0,00,'00','1/1/1900','1/1/1900'

END
END


if i execute it frm analyser as below i get it executed properly

exec usp_updaterate
Eugene Elutin
Eugene Elutin
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5078 Visits: 5478
For some reason I think that you are not executing the proc you think you do.
Try simple test:
Change proc to something like:


ALTER PROCEDURE [dbo].[usp_updaterate]
AS
BEGIN
RETURN;
END



Then execute it from application. If it still gives you the error, then check your connection string...
Or check it before hand :-)

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
ssurekha2000
ssurekha2000
SSC-Enthusiastic
SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)

Group: General Forum Members
Points: 145 Visits: 207
checked the sp with jst return stmt
also checked it with simple select stmt without parameters

checkedd connection string

but still when executed frm application gives the same error
koustav_1982
koustav_1982
SSC-Enthusiastic
SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)

Group: General Forum Members
Points: 151 Visits: 194
Turn on the SQL Server Profiler and then run your app. You will get to see the exact statement that is throwing error. It will help debugging the issue.
Eugene Elutin
Eugene Elutin
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5078 Visits: 5478
ssurekha2000 (10/17/2012)
checked the sp with jst return stmt
also checked it with simple select stmt without parameters

checkedd connection string

but still when executed frm application gives the same error


Have you checked connection string? Looks like you are not connecting to the server/database where you have made and making changes as proc with only RETURN has no character "4" inside of its body ;-)

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
ssurekha2000
ssurekha2000
SSC-Enthusiastic
SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)

Group: General Forum Members
Points: 145 Visits: 207
there is no 4 in the SP
i even checked with select * from table1

i am not sure where do i get it from but i found this on debugging

?cmdupdate.CommandText
"4"
?cmdupdate
{System.Data.SqlClient.SqlCommand}
CommandText: "4"
CommandTimeout: 30
CommandType: Text {1}
Connection: {System.Data.SqlClient.SqlConnection}
Container: Nothing
DesignTimeVisible: True
Notification: Nothing
NotificationAutoEnlist: True
Parameters: {System.Data.SqlClient.SqlParameterCollection}
Site: Nothing
Transaction: Nothing
UpdatedRowSource: Both {3}

cmdupdate is the sqlcommand

cmdupdate.CommandText = "4"

CommandType.StoredProcedure = StoredProcedure {4}


i get this on debugging the application
koustav_1982
koustav_1982
SSC-Enthusiastic
SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)

Group: General Forum Members
Points: 151 Visits: 194
your variable in app must be geting overriden by some other value assignment. check the variable that you are using to call the proc.
Eugene Elutin
Eugene Elutin
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5078 Visits: 5478
can you post the code where you set your CommandText in application?
It is an application issue actually, not SQL one.
Somewhere, instead of stored proc name you use variable with value of "4"

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search