VB.Net中怎么将一个数据集返回?

bafenghan 2004-12-07 11:06:42
我新建一个WebService,自己写了个函数
<WebMethod()> Public Function ReturnValue(byval TempStr as string)--函数返回类型是什么?
Dim CmdStr As String
Dim StrSQL As String
StrSQL = "Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;"
Dim Conn As New SqlConnection(StrSQL)
CmdStr = "select * from customers where customerID=" & TempStr
Dim ADO As New SqlCommand(CmdStr)
ADO.Connection = Conn
Conn.Open()
ADO.ExecuteNonQuery()
ADO.Connection.Close()
End Function

我希望能将select出来的记录集返回给调用的客户端,函数类型应该是什么呢?怎么返回?我刚刚开始用.net,不知道怎么实现啊!
哪位帮帮忙!谢谢了!
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
killerliu 2004-12-08
  • 打赏
  • 举报
回复
么错拉,返回datatable就好了

3tzjq 2004-12-08
  • 打赏
  • 举报
回复
<WebMethod()> Public Function ReturnValue(byval TempStr as string) As DataTable'还可以是|DataSet|Object
Dim CmdStr As String
Dim StrSQL As String
StrSQL = "Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;"
Dim dt as new DataTable
dim oda as new OleDbDataAdapter("select * from customers where customerID=" & TempStr,StrSQL)
oda.Fill(dt)

Return dt
End Function
earlsen 2004-12-08
  • 打赏
  • 举报
回复
up

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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