作者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