V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
BROWNURSIDAE
V2EX  ›  .NET

遇到一个数据查询上的问题,数据库查询没问题,用 WebService 时候就错了

  •  
  •   BROWNURSIDAE · 2015-11-30 11:13:19 +08:00 · 2511 次点击
    这是一个创建于 3070 天前的主题,其中的信息可能已经有所发展或是发生改变。
    vb.net 遇到的一个问题

    “ System.Web.Services.Protocols.SoapException ”类型的未经处理的异常在 System.Web.Services.dll 中发生

    其他信息: System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.Data.OleDb.OleDbException: IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。

       在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)

       在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)

       在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)

       在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)

       在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)

       在 System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)

       在 System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)

       在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

       在 System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)

       在 System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

       在 Service.getEmpInfo() 位置 E:\VB.NET\Restaurant\web\App_Code\Service.vb:行号 71

       --- 内部异常堆栈跟踪的结尾 ---


    这是错误,然后方法是在下面

    <WebMethod()> _
        Public Function getEmpInfo() As DataSet
            cd.CommandText = "SELECT ID,EName,Sex,Age,IDCard,Position,Telephone,ShopID FROM Employee"
            da.Fill(ds.Tables("Employee"))
            Return ds
        End Function

    然后客户端是这样写

    Public Class Manager
        Dim ds As New DataSet
        Dim ws As New localhost.Service()
        Private Sub Manager_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ds = ws.getEmpInfo
            dgvInfo.DataSource = ds.Tables("Employee")
        End Sub
    End Class


    问题是这样的,我在数据库执行按字段查询时候是没问题的,查询语句换成 select * from employee 也没问题,但是加上 id , ename 类似字段查询时候就会报这样的错,但是在数据库里面这样查询又不会错啊,数据库用的是 access ,已经确定是都连上去能用的了,因为其他 WebService 的方法都能正常使用
    BROWNURSIDAE
        1
    BROWNURSIDAE  
    OP
       2015-11-30 11:15:13 +08:00
    在数据库里用这个语句没有任何报错啊,但是 WebService 里面一用,客户端显示时候就会报上面的错误
    BROWNURSIDAE
        2
    BROWNURSIDAE  
    OP
       2015-11-30 11:19:59 +08:00
    已经解决了。。原来 access 字段要[]起来才能用。。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1265 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:07 · PVG 02:07 · LAX 11:07 · JFK 14:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.