TextBox Binding

abhi2823

Active member
Joined
Sep 8, 2007
Messages
32
Programming Experience
1-3
How do i bind textbox to the data whose selection crieteria is based on 2 combo boxes.
I want to use sql and where clause.
right now I am using the following

dt = New DataTable
da = New MySqlDataAdapter("SELECT rates FROM tblratesmaster where date_entry=ComboBox1.selectedindex and broker_firm = ComboBox2.selectedindex", myconnstring)
da.Fill(dt)
cb = New MySqlCommandBuilder(da)
bs.DataSource = dt
TextBox1.DataBindings.Add(New Binding("Text", bs, "rates"))
and I am getting nothing when I run it:confused:
 
Run this code:
VB.NET:
MessageBox.Show("SELECT rates FROM tblratesmaster where date_entry=ComboBox1.selectedindex and broker_firm = ComboBox2.selectedindex")
What do you see in that message box? Now ask yourself if that is really going to use any values you might select in your ComboBoxes.
 
How do i bind textbox to the data whose selection crieteria is based on 2 combo boxes.
I want to use sql and where clause.
right now I am using the following

dt = New DataTable
da = New MySqlDataAdapter("SELECT rates FROM tblratesmaster where date_entry=ComboBox1.selectedindex and broker_firm = ComboBox2.selectedindex", myconnstring)
da.Fill(dt)
cb = New MySqlCommandBuilder(da)
bs.DataSource = dt
TextBox1.DataBindings.Add(New Binding("Text", bs, "rates"))
and I am getting nothing when I run it:confused:

Ugh. MySQL. THat's the msot expensive (time wasting) free database I've never used..
 
cjard, telling someone to use a different database isn't really a solution. There may be a reason that OP is using MySQL. Plenty of developers are and must use MySQL for various reasons. What if the DB will be greater than 4 GB? Where does SQL Server Express get you then? Stuck with purchasing an SQL server license is where. That may not be an acceptable path.

Anyway, the solution to the question is two-fold, and I haven't seen a great deal pf application so far. Consider this code:
VB.NET:
Dim fullName As String = "John Smith"

MessageBox("My name is fullName")
What would you expect to be displayed there? Run it and see. Would you really expect 'fullName' to be interpreted as a variable within that string, when all the other words are just words? So, in that situation, how would you get the message "My name is John Smith" to display? If you can answer that, which you should be able to, then you can at least partly solve your original question.
 
Back
Top