|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 10:39 AM
Points: 2,556,
Visits: 4,398
|
|
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
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 7:03 AM
Points: 90,
Visits: 417
|
|
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
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, December 05, 2012 10:13 PM
Points: 46,
Visits: 120
|
|
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
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 10:39 AM
Points: 2,556,
Visits: 4,398
|
|
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
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, December 05, 2012 10:13 PM
Points: 46,
Visits: 120
|
|
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
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, February 20, 2013 1:39 AM
Points: 70,
Visits: 174
|
|
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.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 10:39 AM
Points: 2,556,
Visits: 4,398
|
|
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
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, December 05, 2012 10:13 PM
Points: 46,
Visits: 120
|
|
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
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, February 20, 2013 1:39 AM
Points: 70,
Visits: 174
|
|
| your variable in app must be geting overriden by some other value assignment. check the variable that you are using to call the proc.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 10:39 AM
Points: 2,556,
Visits: 4,398
|
|
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
|
|
|
|