2013-06-05 174 views
0

你好我是oracle和vb.net的新手。我爲這個應用程序使用vb.net。 我如何將功能的結果從GetMaterialGetDescription傳遞到功能GetDate? 我該怎麼辦?通過vb.net參考

Private Function GetMaterial(ByVal strMaterial As String) As DataSet 

    Dim connectionString As String = "Data Source = ***; User ID = *****; Password = ***;" 
    Dim sqlConnection As OracleClient.OracleConnection = New OracleClient.OracleConnection(connectionString) 

    Dim queryString As String = "select * from abc where device = 'xyz' " 

    Dim sqlCommand As OracleClient.OracleCommand = New OracleClient.OracleCommand(queryString, sqlConnection) 
    sqlCommand.CommandTimeout = 0 

    Dim dataAdapter As OracleClient.OracleDataAdapter = New OracleClient.OracleDataAdapter(sqlCommand) 
    Dim dataSet As DataSet = New DataSet 
    dataAdapter.Fill(dataSet) 

    Return dataSet 

End Function 

Private Function GetDescription(ByVal strMaterial As String, ByVal ListBox1 As String) As DataSet 

    Dim connectionString As String = "Data Source = ***; User ID = ***; Password = ***;" 
    Dim sqlConnection As OracleClient.OracleConnection = New OracleClient.OracleConnection(connectionString) 

    Dim queryString As String = "select * from abc where lpt = '" & ListBox1 & "' and device = '" & strMaterial & "'" 


    Dim sqlCommand As OracleClient.OracleCommand = New OracleClient.OracleCommand(queryString, sqlConnection) 
    sqlCommand.CommandTimeout = 0 


    Dim dataAdapter As OracleClient.OracleDataAdapter = New OracleClient.OracleDataAdapter(sqlCommand) 
    Dim dataSet As DataSet = New DataSet 
    dataAdapter.Fill(dataSet) 

    Return dataSet 

End Function 

Private Function GetDate(ByVal strMaterial As String, ByVal ListBox1 As String, ByVal bdp1 As String) As DataSet 

    Dim connectionString As String = "Data Source = ***; User ID = ***; Password = ***;" 
    Dim sqlConnection As OracleClient.OracleConnection = New OracleClient.OracleConnection(connectionString) 


    Dim queryString As String = "select * from abc where tran_dttm <= to_date('1/31/2012','MM-DD-YYYY') and tran_dttm > to_date('1/30/2012','MM-DD-YYYY')" 


    Dim sqlCommand As OracleClient.OracleCommand = New OracleClient.OracleCommand(queryString, sqlConnection) 
    sqlCommand.CommandTimeout = 0 


    Dim dataAdapter As OracleClient.OracleDataAdapter = New OracleClient.OracleDataAdapter(sqlCommand) 
    Dim dataSet As DataSet = New DataSet 
    dataAdapter.Fill(dataSet) 

    Return dataSet 

End Function 
+0

什麼是ListBox1和bdp1參數?你願意詳細說明它的目的嗎? – Edper

+0

我要顯示的項目是通過函數GetMaterial在某些代碼中按功能進行搜索GetDate – Husna5207

+0

您是否想從「abc」表中獲取記錄,並且用戶是否有該選項通過設備,lpt和設備還是tran_dttm?或者這3個函數會按順序執行? – Edper

回答

0

可以使用的ByRef如果你會做一些改變通過PARAM,如果您不會再使用BYVAL ...

Private Function GetDate(ByVal strMaterial As String, ByVal ListBox1 As String, ByVal bdp1 As String, ByVal dsM as Dataset, ByVal dsD as DataSet) As DataSet 

'code here - example' 
msgbox(dsD.Rows(0).Item(0)) 

End Function 

所以,如果你會使用函數GETDATE與getMaterial dan getDesc作爲參數傳遞....

Dim ds as DataSet = GetDate(.. , .. ,.. , getMaterial(..), getDescription(..)) 
+0

對不起,我不明白, – Husna5207

+0

@ Husna5207:哪部分? – matzone

+0

ByVal dsM as Dataset,ByVal dsD as DataSet – Husna5207