vb.net sqlite how to loop through selected records and pass each record as a parameter to another fu
Posted
by mazrabul
on Stack Overflow
See other posts from Stack Overflow
or by mazrabul
Published on 2010-06-05T05:57:59Z
Indexed on
2010/06/05
6:02 UTC
Read the original article
Hit count: 245
Hi,
I have a sqlite table with following fields:
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
I want to loop through the records based on language and other conditions and then pass the current selected record to a different function. So I have the following mixture of actual code and psudo code. I need help with converting the psudo code to actual code, please. I am finding it difficult to do so.
Here is what I have:
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
Many thanks for your help.
© Stack Overflow or respective owner