-1
当我第一次使用web服务(asmx)并返回DataTable
到我的aspx项目时,一切都很好。但是,如果我再次在该aspx上使用web服务,则以前的DataTable
对象完全为空。这是为什么?为什么我不能多次使用我的web服务?
这是我的web服务方法:
<WebMethod()> _
public Function QueryGeneralText() As DataTable
ds.Reset()
com.Parameters.Clear()
com.CommandText = queryString
com.CommandType = select booksID from Books"
com.Connection = con
conectarBD()
da = New SqlDataAdapter(com)
da.Fill(ds)
con.Close()
Return ds.Tables(0)
End Function
在aspx.vb部分:
Public Sub CreateDatatable()
Dim example1 As DataTable = ws.QueryGeneralText() ' RETURNS DATA
Dim example2 As DataTable = ws.QueryGeneralText() ' RETURNS DATA, BUT EXAMPLE ITS EMPTY
End Sub
您在发布的第一个代码块中出现语法错误(注意突出显示的颜色已混乱)。 – gunr2171