Binding Text Boxes to a Dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there
I am new to VB.Net (formerly a Centura 'Gupta' programmer) and just trying to do a simple excercise out of the help to populate a couple of text fields on a form by using a parameterized query.
ie. Walkthrough 'Displaying Data in a Windows Form Using a Parameterized Query
Sounds simple but for some reason when I get to the step where you are supposed to 'Expand the (DataBindings) node, and for the Text property, expand DsAuthors1, expand authors, and select au_id from the drop-down list.
I don't have a drop down list?! It's empty
Please help me find what I'm missing here

I have the following on my form
OdbcDataAdapter with a simple select command 'SELECT MBR_SAID, MBR_SURNAME, MBR_ADDR1 FROM FHP_MBR WHERE (MBR_SAID = ?)
OdbcConnection (to an Access database
and a DataSet (dsMbr

The following code is for the button click
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
OdbcDataAdapter1.SelectCommand.Parameters("mbr_said").Value = dfnMbr_said.Tex
dsMbr.Clear(
OdbcDataAdapter1.Fill(dsMbr
End Su

So what am I missing here please? I know it's probably simple... I just need a jumpstart
How do I bind the results of this query to the appropriate fields
I am using the VB.Net Standard edition and have therefore had to export my Oracle tables into Access for the purpose of this excercise since I believe you need the full blown Enterprise edition of Visual Studio to connect to Oracle
Thanks
Marnie
 
Hi Ken
Thanks for your response

I did try using something similar to that ie

Protected Sub BindControls(
dfsMbr_Surname.DataBindings.Add(New Binding("Text", dsMbr, "mbr.mbr_surname")
End Su

Should that work too

Although I wasn't sure then where to call BindControls() from? Where are you suggesting to put the code
TextBox2.DataBindings.Add("Text", ds.Tables(0), "CategoryName"

Does Tables(0) select the first table (being the only one in my case) in the query

I thought that I was going to be able to do this by going through the properties of TextBox2 (in my case dfsMbr_Surname) as per the documentation. I assume the code you gave me is generated for you if you do it through the properties dialog
Still wondering why nothing appeared in the Data Bindings section of the datafield properties
Thanks
Marnie


----- Ken Tucker [MVP] wrote: ----

Hi

To bind a textbox to a datasource. This will bind the CategoryName
field of a dataset ds to textbox2

TextBox2.DataBindings.Add("Text", ds.Tables(0), "CategoryName"

To use the oracle data provider you need to add a reference to
system.data.oracleclient.dll

http://msdn.microsoft.com/library/d...racleClientOracleDataAdapterClassctorTopic.as

Ke
-----------------
 
Hi,

It should. I dont think you need the mbr. Try this.

dfsMbr_Surname.DataBindings.Add(New Binding("Text", dsMbr, "mbr_surname"))

Ken
 
Back
Top