为什么我的webservers 没有生成结果集,xml 显示结果如下:

zoulipeng 2003-08-22 02:46:59
Imports System.Web.Services

<WebService(Namespace := "http://tempuri.org/")> _
Public Class Service1
Inherits System.Web.Services.WebService

#Region " Web 服务设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Web 服务设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加您自己的初始化代码

End Sub

'Web 服务设计器所必需的
Private components As System.ComponentModel.IContainer

'注意:以下过程是 Web 服务设计器所必需的
'可以使用 Web 服务设计器修改此过程。
'不要使用代码编辑器修改它。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: 此过程是 Web 服务设计器所必需的
'不要使用代码编辑器修改它。
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

#End Region

' Web 服务示例
' HelloWorld() 示例服务返回字符串 Hello World。
' 若要生成项目,请取消注释以下行,然后保存并生成项目。
' 若要测试此 Web 服务,请确保 .asmx 文件为起始页
' 并按 F5 键。
'
'<WebMethod()> Public Function HelloWorld() As String
' HelloWorld = "Hello World"
' End Function

<WebMethod(Description:="数据库数据转换成xml的方法")> Public Function readxml()

Dim LstrSQL As String
Dim LConn As System.Data.OleDb.OleDbConnection
'Dim LCmd As System.Data.OleDb.OleDbCommand
Dim LAdapter As System.Data.OleDb.OleDbDataAdapter
Dim da As New DataSet()
Dim MyDataGrid As New DataGrid()
LstrSQL = "SELECT A.STCDT, A.YMDHM, B.TABLECODE FROM dbo.TV_MAXNOTABLECODE_V A INNER JOIN dbo.TV_MAX_V B ON A.STCDT = B.STCDT AND A.YMDHM = B.YMDHM AND B.TABLECODE <> 'ST_RNFL_R'"
Try
LConn = New System.Data.OleDb.OleDbConnection(ConnString)
If LConn.State <> ConnectionState.Open Then LConn.Open()
LAdapter = New System.Data.OleDb.OleDbDataAdapter(LstrSQL, LConn)
da.Reset()
LAdapter.Fill(da, "TableQuery")
' Create and fill a DataSet.
'Dim ds As DataSet = New DataSet()
'LCmd.Fill(ds)
' Bind MyDataGrid to the DataSet. MyDataGrid is the
' ID for the DataGrid control in the HTML section.
MyDataGrid.DataSource = da.Tables("TableQuery").DefaultView
MyDataGrid.DataBind()

Catch ex As Exception
exNoteBugs(ex.Message, "Public Function BindingRepeater")
Finally
'释放资源
DisposeObject(LConn)
LAdapter.Dispose()
da.Dispose()
End Try
'Return Context.Timestamp.TimeOfDay.ToString
'Return Server.MachineName



End Function

end class
















xml 显示结果如下:

<?xml version="1.0" encoding="utf-8" ?>
<anyType xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" xmlns="http://tempuri.org/" />

1。什么东西都没显示,为什么,我的数据库中有数据,
2。我要在asp.net 中如何调用我的这个webservers 应用呢?
...全文
43 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
richielou 2003-08-23
  • 打赏
  • 举报
回复
你的函数需要return一个dataset对象(fill data后,将其return) !
为什么要在WebService中使用DataGrid Control?
guoyan19811021 2003-08-23
  • 打赏
  • 举报
回复
使用web service代理类

dim qu as new localhost.qu()
qu.readxml()...
..............
xiangzionest 2003-08-22
  • 打赏
  • 举报
回复
1.应该是没有在数据库中读出数据,查看数据库联接
2.在asp.net中调用
首先,在asp.net应用程序中添加web引用,找到你的webservice,例如:输入http://localhost/service/service1.asmx
然后在程序中
用service1 myService=new service1();
使用myService.readxml()即可,



补充一句,webservice要用返回值

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧