In an attempt to do a project recently, I've bumped into a problem with textbox and databinding. I have a multiple line textbox and wish to display the address of a company. However the full address of the company is stored in multiple columns inside my database. When implemented, I can only display the street address onto my textbox. I'm currently databinding the textbox to the address field in my customer table. Is there a way to display more than one database column onto a textbox Perhaps bind more than one piece of data to the textbox
Thanks

TextBox (multiple line) & Databinding
ShaulB
hi, JinMaster
you are most welcome my friend
prof.Scuba
Hi shakalama,
Thank you for your tip, the textbox is now able to display the whole address. However whenever I choose the company from a comboBox, it doesn't display the correct address.
Here's part of the code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.TextBox2.Text = Me.TblcustomerBindingSource.Current("Address") & "," & Me.TblcustomerBindingSource.Current("City") & ", " & Me.TblcustomerBindingSource.Current("State") & " " & Me.TblcustomerBindingSource.Current("Zip")
End Sub
I suspect the problem lies within the Current function not being able to detect which choice is made by the comboBox1. This was never a problem before because I bound the textbox to the address field, and so whenever the index is changed inside comboBox1, the address field changes dynamically inside textBox2.
Tytech
hi,
simply open your dataset in design view and right click and select add query and follow the wizard you can build your query as sql statment, or stored procedure.
as sql statment its like that:
SELECT [Column1] & " " & [Column2] AS MyAddress
FROM AddressTable;
i've tried to make it right now but select with returned rows was not enabled i don't know why may be its not active in express edition
May be there are a way to do that as stored procedure unfortunatly i don't know much about stored procedures
may be someone else can help in this
yangjdong
Hi
Thanks for replying so quickly. The main problem I'm still experiencing is how to tie the sql query and the textbox together. I've already created a query that retrives the street,city,state and zip from my table. But currently I don't know how to display it inside my textbox
Willbu
hi,
you can review those links for data access
http://msdn2.microsoft.com/en-us/library/ms184649.aspx
http://msdn.microsoft.com/vbasic/reference/data/default.aspx pull=/library/en-us/dnsql90/html/mandataaccess.asp#mandataac_topic5
http://www.connectionstrings.com/
you will use the same code to connect to your database in asp.net
you can access to your asp controls by useing the id of this control as long as it has id you can use that id to assign or change values to it programaticlly
i don't know much about detailsview
hope that helps
st3ph3n
hi,
the problem lies within your dataset, this code for the binding source not the combobox
if you want to select the record from the combobox it will be different code you will deal with your dataset, or your database
in the top of your code view you will find 2 combobox at top select your binding source at left side and positionchanged at right side it will add a new sub to your code put this code in that sub it will looks exactly like that
Private Sub TblcustomerBindingSource_PositionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblcustomerBindingSource.PositionChanged
Me.TextBox2.Text = Me.TblcustomerBindingSource.Current("Address") & "," & Me.TblcustomerBindingSource.Current("City") & ", " & Me.TblcustomerBindingSource.Current("State") & " " & Me.TblcustomerBindingSource.Current("Zip")
End Sub
if something changed in that code it will not work properly
hope it helps
kthiagar
hi,
my friend What i mean is that the query will join the columns together like "4 somewhat street in somewhat city" it will join the columns data as if its one column so that you can call that query
ok my friend i'll tell you other way , its not the best but it works
in your form designer
1) don't bound your textbox to anything
2) double click your binding source and change the eventhandler to positionchanged in code view
Private Sub MyBindingSource_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBindingSource.PositionChanged
'Dont bind your text box to anything
TextBox1.Text = MyBindingSource.Current(
"street") & ", " & MyBindingSource.Current("city") & ", " & MyBindingSource.Current("State") & ", " & MyBindingSource.Current("zipcode") End Subhope it helps
Craig Mackles
hi,
there are many ways to do that , the best way in my opinion to join the columns in one query column and to bind your data to the query not the table directly
Hope it helps
Zolt
bbutcher8404
Richard Chenglo
Olmy