Click here to Skip to main content
15,895,793 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have tried every trick I know to get this code working, and the parameter is definitely being given a value. I'm thinking maybe there's just some typo that I'm not seeing.

VB
'pulls a list of forms for the selected pokemon
Dim SqlQry As String = "SELECT [Pokemon_forms].[pokemon_id], [Pokemon].[id], [Pokemon].[identifier], [Pokemon_forms].[form_identifier] " &
    "FROM [Pokemon], [Pokemon_forms] WHERE (([Pokemon]![id]=[Pokemon_forms]![pokemon_id])) AND [Pokemon]![identifier] = ?;"

DbCommand = New OleDbCommand(SqlQry, DbConnection)
Dim IdentifierParam As New OleDbParameter("?", OleDbType.VarChar)
DbCommand.Parameters.Add(IdentifierParam)
IdentifierParam.Value = PokedexList.SelectedItems(0).Text

DbConnection.Open()

'error occurs here and states that one or more parameters has no value
Dim da As OleDbDataAdapter = New OleDbDataAdapter(SqlQry, DbConnection)

Dim ds As DataSet = New DataSet

da.Fill(ds, "Pokemon")

Dim dt As DataTable = ds.Tables("Pokemon")

Dim row As DataRow

For Each row In dt.Rows
    Dim FormIdentifier As String = row("form_identifier")

    If FormIdentifier = "" Then
        PkmFormList.Items.Add("Normal")
    Else
        FormIdentifier = StrConv(FormIdentifier, vbProperCase)

        PkmFormList.Items.Add(FormIdentifier)
    End If
Next

DbConnection.Close()


My example when I debug is to click "Absol" in the PokedexList, and that's when this code runs. If done correctly, it would bring up a list of Absol's forms in the PkmFormList (i.e. it should bring up "Normal" and "Mega"). I have run the SqlQry in MS Access and when I enter Absol as the parameter value it runs the query as expected, but when run in vb.net it gives the title error. I have used console.write and breakpoints to verify that IdentifierParam.Value is indeed Absol, and it is. Any ideas?
Posted
Updated 9-Nov-15 14:49pm
v2
Comments
Patrice T 9-Nov-15 20:30pm    
Do you have an error ?
Which error message ? Where ?
KitsunePhoenix 9-Nov-15 20:33pm    
it stops at the data adapter and says one or more required parameters has no value
Patrice T 9-Nov-15 20:46pm    
Improve your question with the error message and place a comment where the error occurs.
KitsunePhoenix 9-Nov-15 20:49pm    
i thought the question was obvious but okay, any ideas where i'm going wrong in the code?
Richard Deeming 10-Nov-15 8:28am    
Shouldn't those ! 's be . 's?

Eg: [Pokemon]![id] should be [Pokemon].[id]

1 solution

I found the answer, it was right in front of my face the whole time.

Dim da As OleDbDataAdapter = New OleDbDataAdapter(SqlQry, DbConnection)


should have been

Dim da As OleDbDataAdapter = New OleDbDataAdapter(DbCommand)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900