Try
con.Open()
            MsgBox(con)
            qry = "Select sum(slpri) From sales where slsnum > '" & 10000 & "'"
            cmd = New MySqlCommand(qry, con)
            dr = cmd.ExecuteReader()
            If dr.Read() Then
                sum1 = (dr("slpri").ToString)
                stotxt.Text = sum1
            End If
            con.Close()
        Catch ex As Exception
            MsgBox("ERROR:" + ex.Message, MsgBoxStyle.Exclamation, "ERROR")
            con.Close()
        End Try            

I presume the error is from

sum1 = (dr("slpri").ToString)

My guess is that you haven't specified a field name for the SUM in the query. I'm not that familiar with mysql but you could try either changing the query to

qry = "Select total=sum(slpri) From sales where slsnum > '" & 10000 & "'"

then using

stotxt.Text = dr("total")

or (this may work) leaving the query as is and using

stotxt.Text = dr(0)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.