In a form using VB (please, no <ASP:> things unless necessary), I need a simple way to execute a SELECT command against a SQLEXPRESS db, retrieve data based on the query, and fill a textbox with its output or a boolean value that, at least, lets me know if there were any matches at all. Here's my code so far:
Dim myFabDataSource as New SqlDataSource
String = ConfigurationManager.Conne
andType = SqlDataSourceCommandType.T
and = "select * FROM Insect_Table where insectname = @insectname"
Feedback_Box1.text = myFabDataSource.SelectComm
As you can probably see, when I run it, my Feedback_Box1 gets filled with the words, "select * FROM Insect_Table where insectname = @insectname", which really doesn't do anybody any good. I've even found this question asked quite directly at http://forums.asp.net/t/1072103.aspx
, but I don't understand the dataview stuff at the end and how it solves the objective. If you could explain it, that would be great. Here is the solution provided by user, ecbruck. Please visit that URL or check this out. This appears to be the accepted solution:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myDataSource As New SqlDataSource()
ing = ConfigurationManager.Conne
Type = SqlDataSourceCommandType.T
= "SELECT * FROM [Products] WHERE ProductID=@ProductID"
Dim dv As Data.DataView = CType(myDataSource.Select(
TextBox1.Text = dv(0)("ProductName").ToStr
Now, I suppose that what I need occurs in the line----> TextBox1.Text = dv(0)("ProductName").ToStr
ing but I don't understand what ProductName is or if that should be substituted with the search term. I more or less understand it all except for that business at the end. I suppose what I need is someone to please explain to me this DataView business and how I can use it or some other tool to get rows from the DB or boolean values that tell me if rows exist, etc. Thank you.