我有以下字段的SQLite表:vb.net sqlite的如何通過選擇循環記錄和傳遞每一個記錄作爲參數傳遞給另一個函數
Langauge level hours
German 2 50
French 3 40
English 1 60
German 1 10
English 2 50
English 3 60
German 1 20
French 2 40
我想通過記錄迴路基於語言和其他條件,然後將當前選定的記錄傳遞給不同的功能。 所以我有以下實際代碼和psudo代碼的混合。我需要將psudo代碼轉換爲實際代碼的幫助。我發現很難這樣做。
以下是我有:
Private sub mainp()
Dim oslcConnection As New SQLite.SQLiteConnection
Dim oslcCommand As SQLite.SQLiteCommand
Dim langs() As String = {"German", "French", "English"}
Dim i as Integer = 0
oslcConnection.ConnectionString = "Data Source=" & My.Settings.dbFullPath & ";"
oslcConnection.Open()
oslcCommand = oslcConnection.CreateCommand
Do While i <= langs.count
If langs(i) = "German" Then
oslcCommand.CommandText = "SELECT * FROM table WHERE language = '" & langs(i) & "';"
For each record selected 'psudo code
If level = 1 Then 'psudo code
update level to 2 'psudo code
minorp(currentRecord) 'psudo code: calling minorp function and passing the whole record as a parameter
End If 'psudo code
If level = 2 Then 'psudo code
update level to 3 'psudo code
minorp(currentRecord) 'psudo code: calling minorp function and passing the whole record as a parameter
End If 'psudo code
Next 'psudo code
End If
If langs(i) = "French" Then
oslcCommand.CommandText = "SELECT * FROM table WHERE language = '" & langs(i) & "';"
For each record selected 'psudo code
If level = 1 Then 'psudo code
update level to 2 'psudo code
minorp(currentRecord) 'psudo code: calling minorp function and passing the whole record as a parameter
End If 'psudo code
If level = 2 Then 'psudo code
update level to 3 'psudo code
minorp(currentRecord) 'psudo code: calling minorp function and passing the whole record as a parameter
End If 'psudo code
Next 'psudo code
End If
Loop
End Sub
你的幫助非常感謝。
你能告訴我如何用sqlite做到這一點。我在使用vb.net和sqlite查找示例時遇到了一些困難。謝謝 – mazrabul 2010-06-06 10:04:48
既然你顯示僞代碼,我假設你要麼從你的查詢中獲取DataSet或DataReader。檢查DataTable和DataReader類,它們都具有DataRows集合(用於DataReader的行?)。 – Raj 2010-06-06 10:27:51
是的,我正在使用數據集。檢查了課程,發現我在尋找什麼。謝謝 – mazrabul 2010-06-06 12:11:19