Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

error - incorrect syntax near '4' Expand / Collapse
Author
Message
Posted Monday, October 15, 2012 8:06 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, April 03, 2014 10:10 AM
Points: 2,792, Visits: 4,874
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!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1372747
Posted Monday, October 15, 2012 11:41 AM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, November 23, 2013 9:32 AM
Points: 90, Visits: 418
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
Post #1372856
Posted Tuesday, October 16, 2012 2:48 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, February 20, 2014 7:28 AM
Points: 75, Visits: 197
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
Post #1373080
Posted Tuesday, October 16, 2012 4:41 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, April 03, 2014 10:10 AM
Points: 2,792, Visits: 4,874
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!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1373122
Posted Wednesday, October 17, 2012 3:06 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, February 20, 2014 7:28 AM
Points: 75, Visits: 197
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
Post #1373693
Posted Wednesday, October 17, 2012 3:44 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, March 08, 2014 5:07 PM
Points: 72, Visits: 180
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.
Post #1373707
Posted Wednesday, October 17, 2012 4:10 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, April 03, 2014 10:10 AM
Points: 2,792, Visits: 4,874
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!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1373714
Posted Wednesday, October 17, 2012 10:23 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, February 20, 2014 7:28 AM
Points: 75, Visits: 197
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
Post #1373936
Posted Wednesday, October 17, 2012 11:34 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, March 08, 2014 5:07 PM
Points: 72, Visits: 180
your variable in app must be geting overriden by some other value assignment. check the variable that you are using to call the proc.
Post #1373968
Posted Wednesday, October 17, 2012 1:57 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, April 03, 2014 10:10 AM
Points: 2,792, Visits: 4,874
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!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1374035
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse