davidxc davidxc - 2 months ago 11
MySQL Question

How to target and display specific database fields for my .Net page

I have this simple vb code to pull out each row in the database as requested.

dbAD.SelectCommand = New OleDbCommand(“SELECT * FROM Profile ORDER BY Name ASC", dbConnect)
dbAD.Fill(dbRS, “Profile")
If dbRS.Tables("Profile").Rows.Count > 0 Then
For Each profile As DataRow In dbRS.Tables("Profile").Rows
Response.Write(“Profiles: “ & Profile(“FullName”) & “&nbsp; &nbsp; &nbsp; &nbsp; “ & Profile(“Email”) & “&nbsp; &nbsp; &nbsp; &nbsp; “ & Profile(“Password”) & “&nbsp; &nbsp; &nbsp; &nbsp; “ & Profile(“Academy”) & “<br />”)
Next
End If


My database has the following columns:

FullName,
Email,
Password,
Academy,

Say I wanted to target "Mary Jones" (who appears in FullName column) and just display her information, or just 1 piece of her information, say her Password, do I just have to change the SELECT to something like:

SELECT * from Profile WHERE FullName = Mary Jones


Or is there much more to it?

Doesn't

Eval()


have to be used in order for specific data requests from the database?

Answer

Consider reading about basic SQL queries but yes you need to place a WHERE condition for a better efficient query like

SELECT * from Profile WHERE FullName = 'Mary Jones'

Again since you want only password field consider getting only that field instead

SELECT `password` from Profile WHERE FullName = 'Mary Jones'

Though, you can get that specific field at your application end from the dbRS.Tables("Profile")

Comments