作者gugugogo (淡)
看板Visual_Basic
標題[.NET]請問function的傳回值
時間Tue Jul 26 14:04:42 2005
我在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
1F:推 fumizuki:你沒給參數 61.222.155.162 07/26
2F:推 fumizuki:物件要指定 → Set xxx = xxx 61.222.155.162 07/26
3F:推 gugugogo:問題是出在ShowPerson()這行... 61.228.174.58 07/26
4F:推 linmic:ShowPerson(這裡面要放你的DataGrid參數) 220.139.173.98 07/26