Use value returned from database field as variable in sub function

  • Thread starter Thread starter Stephen Ancliffe
  • Start date Start date
S

Stephen Ancliffe

Okay how would I do this?



I want to query an access databases and then display a graphic based on the
value of a field in the query.



For example the data base would be something like this:



Name: Password: Rating

Steve password 4

Chris password 2





The graphic that would be displayed be based on the rating. For example for
a rating of 1 the graphic 1Star.gif would be displayed and so on. How do I
use a value returned from a database as a variable in a sub function?





Imagine the code would look something like this



Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then

MyDatabaseQuerry()

End If

End Sub



Function MyDataBaseQuerry()

'Query Database and get results

End function



Sub DisplayGraphic (Sender As Object, E As EventArgs)

MyDatabaseQuerry()

'Display graphic based on database results

Dim graphic as string

Graphic = some database value

End Sub



Thank you in advance for any help



Stephen Ancliffe

www.carbonile.com
 
use the ExecuteScalar method of your command object....

graphic = cmd.ExecuteScalar
Where the cmd.CommandText is a query returning the string name you want to
set graphic to.
 
Back
Top