本文介绍了无法执行查询[从tkt中选择统计信息,其中tkt ='12345']的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我正在使用NhiberNate和VB.NET
我的应用程序中出现无法执行查询"错误.
我的代码如下.

hello ,
i am working with NhiberNate and VB.NET
i am getting "could not execute Query" error in my applicaion.
my code is as follows.

Public Function GetTicketStatus(ByVal tkt As String) As String
            Try
                Dim strQuery As String = "Select stat from tkt where tkt = ''" & tkt & "''"
                Dim resultData = GetISession.CreateSQLQuery(strQuery).List()
                If resultData IsNot Nothing AndAlso resultData.Count > 0 Then
                    Return resultData(0).ToString()
                Else
                    Return String.Empty
                End If
            Catch ex As Exception
                
            End Try
        End Function


堆栈跟踪如下所示


The stack Trace is as follows

Message: could not execute query
[ Select stat from tkt where tkt =  = ''12345'' ]
[SQL: Select stat from tkt where tkt =  = ''12345'']
Stack Trace :
   at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in E:\sources\NHibernate\src\NHibernate\Loader\Loader.cs:line 1660
   at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) in E:\sources\NHibernate\src\NHibernate\Loader\Loader.cs:line 1575
   at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) in E:\sources\NHibernate\src\NHibernate\Loader\Loader.cs:line 1569
   at NHibernate.Loader.Custom.CustomLoader.List(ISessionImplementor session, QueryParameters queryParameters) in E:\sources\NHibernate\src\NHibernate\Loader\Custom\CustomLoader.cs:line 272
   at NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery customQuery, QueryParameters queryParameters, IList results) in E:\sources\NHibernate\src\NHibernate\Impl\SessionImpl.cs:line 2107
   at NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters, IList results) in E:\sources\NHibernate\src\NHibernate\Impl\SessionImpl.cs:line 2090
   at NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters) in E:\sources\NHibernate\src\NHibernate\Impl\SessionImpl.cs:line 2066
   at NHibernate.Impl.SqlQueryImpl.List() in E:\sources\NHibernate\src\NHibernate\Impl\SqlQueryImpl.cs:line 127
   at BusinessClasses.TicketHeaderBll.GetTicketStatus(String tkt) in J:\BusinessClasses\TicketHeaderBll.vb:line 4803
Inner Exception :  - Object reference not set to an instance of an object.


在内部异常中,它是对象引用未设置为对象的实例".
在我的数据库和我的机器上可以正常工作.但是在极少数情况下,这种情况会出现.
任何人都可以解释一下如何解决它.


in inner exception it is "Object reference not set to an instance of an object" .
with my database and in my machine it is correctly working.but in rare situations this is coming.
any one can explain please how to resolve it.

推荐答案



  1. tkt不存在
  2. 字段tkt不存在
  3. 字段tkt是数字数据类型(不是varchar)

  1. Table tkt doesnt'' exists
  2. Field tkt doesn''t exists
  3. Field tkt is numeric data type (not varchar)



请检查表和字段的名称(注意:在使用表名称的主题中:"Table1"而不是"tkt").
如果tkt字段是数字数据typ,则应以这种方式编写查询:



Please check the name of table and field (NOTE: in a subject you have used table name: ''Table1'' instead ''tkt'').
If tkt field is numeric data typ , you should write query in that way:

SELECT [stat]
FROM Table1 where tkt = 1234


这篇关于无法执行查询[从tkt中选择统计信息,其中tkt ='12345']的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 01:24