[.NET]請問function的傳回值
我在module裡宣告一個函數
Public Function ShowPerson(ByRef DataGrid1 As DataGrid) As DataTable
Dim connStr, selectCmd As String
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PERSONDB.mdb"
selectCmd = "Select * From PERSON Order By id_no DESC"
Dim conn As OleDbConnection, myAdapter As OleDbDataAdapter
Dim myDataSet As New DataSet
conn = New OleDbConnection(connStr)
conn.Open()
myAdapter = New OleDbDataAdapter(selectCmd, conn)
myAdapter.Fill(myDataSet, "PERSON")
Return myDataSet.Tables("PERSON")
End Function
然後我在主程式裡面呼叫
ShowPerson()
mydatagrid.DataSource = ShowPerson(mydatagrid)
卻有錯誤
請問這要我要如何呼叫他呢
我是想要傳回一個dataset給在主程式裡的datagrid使用
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.174.58
推
61.222.155.162 07/26, , 1F
61.222.155.162 07/26, 1F
推
61.222.155.162 07/26, , 2F
61.222.155.162 07/26, 2F
推
61.228.174.58 07/26, , 3F
61.228.174.58 07/26, 3F
推
220.139.173.98 07/26, , 4F
220.139.173.98 07/26, 4F
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章