MySQL Forums
Forum List  »  German

AddWithValue MySqlType.Decimal
Posted by: Lothar Rappsilber
Date: October 18, 2021 07:55AM

Hallo,
ich komme leider nicht weiter. Arbeite mit vs2019 und vb. Habe eine cascadierende DropDownList erstellt (Land, Bundesland, Region). Bei Land, wo ich kein AddWithValue verwenden muss, funktioniert es tadellos. Bei Bundesland, wo ich AddWithValue verwenden muss, krieg ich es nicht gebacken. Alle id's sind als Integer definiert. Der relevante Code:

Protected Sub idLand_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
DropDownBundesland.Items.Clear()
DropDownBundesland.Items.Add(New ListItem("--Select Country--", ""))
DropDownRegion.Items.Clear()
DropDownRegion.Items.Add(New ListItem("--Select City--", ""))

DropDownBundesland.AppendDataBoundItems = True
Dim strConnString As [String] = ConfigurationManager _
.ConnectionStrings("conString").ConnectionString
Dim strQuery As [String] = "Select Bundesland, idBundesland, idLand from Campingplatz ORDER BY Bundesland ASC where idLand = @LandID Group BY Bundesland"
Dim con As New MySqlConnection(strConnString)
Dim cmd As New MySqlCommand()
cmd.Parameters.AddWithValue("@LandID", MySqlDbType.Decimal).Value = DropDownLand.SelectedItem.Value
cmd.CommandType = CommandType.Text
cmd.CommandText = strQuery
cmd.Connection = con
Try
con.Open()
DropDownBundesland.DataSource = cmd.ExecuteReader()
DropDownBundesland.DataTextField = "Bundesland"
DropDownBundesland.DataValueField = "idBundesland"
DropDownBundesland.DataBind()
If DropDownBundesland.Items.Count > 1 Then
DropDownBundesland.Enabled = True
Else
DropDownBundesland.Enabled = False
DropDownRegion.Enabled = False
End If
Catch ex As Exception
'Throw ex
Finally
con.Close()
con.Dispose()
End Try
End Sub

Bitte um Hilfe!

Options: ReplyQuote


Subject
Views
Written By
Posted
AddWithValue MySqlType.Decimal
448
October 18, 2021 07:55AM
189
November 05, 2021 01:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.