我花了最近2天试图通过检查参数来识别问题,从web方法中删除大部分代码,最后我能够将问题跟踪到这个存储过程.
CREATE PROCEDURE [dbo].[spUnionServices]@freetext NVARCHAR(50),@offset int,@fetch intAS SET NOCOUNT ON;BEGINSELECT IDphoto AS IDservice,photos.IDuser,photoCaption AS serviceTitle,photoDate as serviceDate,photofilename AS servicePhoto,'Photo' AS service,photopublished as servicePublished,inap,hashTags,KEY_TBL.RANK,screenname AS IDname FROM photos INNER JOIN freetexttable(photos,(photoCaption),@freetext) AS KEY_TBL ON photos.IDphoto = KEY_TBL.[KEY] INNER JOIN editorDetail ON editorDetail.IDuser = photos.IDuser ORDER BY RANK DESC OFFSET @offset ROWS FETCH NEXT @fetch ROWS ONLY END
这是我如何从web方法连接到存储过程
StringBuilder SBsmallSquares = new StringBuilder();sqlConnection sqlConnection1 = new sqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); using (sqlConnection1) { sqlCommand cmd = new sqlCommand(); sqlDataReader ReaderPopup; cmd.CommandText = "spUnionServices"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = sqlConnection1; cmd.Parameters.AdDWithValue("@offset",offset); cmd.Parameters.AdDWithValue("@fetch",fetch); cmd.Parameters.AdDWithValue("@freetext",fts); sqlConnection1.open(); ReaderPopup = cmd.ExecuteReader(); if (ReaderPopup.HasRows) { while (ReaderPopup.Read()) { //creating the string to return. Here there is no problem. } return SBsmallSquares.ToString(); } else return string.Empty;
如果有人能够在第一次尝试运行存储过程时发现我遇到此问题,我将不胜感激.谢谢!
解决方法 您应该重试此错误.在可用性事件(例如,升级)期间,DB可以移动到不同的机器,并且fdhost需要再次与sql实例配对.通常,配对过程发生在第一个自由文本查询或需要时.您可能第一次看到该过程中的超时.它应该帮助你重试.如果这是非常一致的,那么服务中可能存在错误并让我们知道.我会帮你进一步调试. 总结以上是内存溢出为你收集整理的c# – Ajax webmethod无法在第一次尝试时触发存储过程全部内容,希望文章能够帮你解决c# – Ajax webmethod无法在第一次尝试时触发存储过程所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)