By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,365 Members | 2,946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,365 IT Pros & Developers. It's quick & easy.

how to specify which row is to be displayed?

P: n/a
Hello:

I have a form which I would like to fill with data from one row of an ODBC
database table.

I have created the Table adapter and I have a query:

SELECT PATIENT.Name, PATIENT.address
FROM PATIENT
WHERE PatientID = ?

This gives me a GetDataBy(PatientID) method.

How can I then drag the controls onto the form and specify they be filled
with the row which is specified by PatientID?

There is also a Query that gets All Rows for a DataGridView in another form
which the drag and drop seems to default to such that I always get the first
row and not the row I specified programaticaly.

If I can't drag/drop then how do I change ordinary textboxes to be databound
by the GetDataBy(PatientID) query?

Thanks

Edwin
Feb 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Feb 23, 7:04 pm, "Edwin Smith" <smithgold...@aol.comwrote:
Hello:

I have a form which I would like to fill with data from one row of an ODBC
database table.

I have created the Table adapter and I have a query:

SELECT PATIENT.Name, PATIENT.address
FROM PATIENT
WHERE PatientID = ?

This gives me a GetDataBy(PatientID) method.

How can I then drag the controls onto the form and specify they be filled
with the row which is specified by PatientID?

There is also a Query that gets All Rows for a DataGridView in another form
which the drag and drop seems to default to such that I always get the first
row and not the row I specified programaticaly.

If I can't drag/drop then how do I change ordinary textboxes to be databound
by the GetDataBy(PatientID) query?

Thanks

Edwin
Declare a DataSet. Fill the DataSet with data (use a
SqlDataAdapter). Bind a grid to the DataSet using gridView.DataSource
= myDataSet;. Add some text controls to your form. Set the data
binding properties to bind to your DataSet. The gridView control will
take care of the rest (i.e. the currencyManager).

myGridView.DataSource = myDataSet.Tables["Patient"];

txtPatientName.SetDataBinding (myDataSet.Tables["Patient"], "Name");
txtPatientAddress.SetDataBinding (myDataSet.Tables["Patient"],
"Address");

this should do it, every time you choose another patient in the grid,
the text controls will be updated appropriately.
Jon

Feb 24 '07 #2

P: n/a

<ma*****@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
On Feb 23, 7:04 pm, "Edwin Smith" <smithgold...@aol.comwrote:
>Hello:

I have a form which I would like to fill with data from one row of an
ODBC
database table.

I have created the Table adapter and I have a query:

SELECT PATIENT.Name, PATIENT.address
FROM PATIENT
WHERE PatientID = ?

This gives me a GetDataBy(PatientID) method.

How can I then drag the controls onto the form and specify they be filled
with the row which is specified by PatientID?

There is also a Query that gets All Rows for a DataGridView in another
form
which the drag and drop seems to default to such that I always get the
first
row and not the row I specified programaticaly.

If I can't drag/drop then how do I change ordinary textboxes to be
databound
by the GetDataBy(PatientID) query?

Thanks

Edwin

Declare a DataSet. Fill the DataSet with data (use a
SqlDataAdapter). Bind a grid to the DataSet using gridView.DataSource
= myDataSet;. Add some text controls to your form. Set the data
binding properties to bind to your DataSet. The gridView control will
take care of the rest (i.e. the currencyManager).

myGridView.DataSource = myDataSet.Tables["Patient"];

txtPatientName.SetDataBinding (myDataSet.Tables["Patient"], "Name");
txtPatientAddress.SetDataBinding (myDataSet.Tables["Patient"],
"Address");

this should do it, every time you choose another patient in the grid,
the text controls will be updated appropriately.
Jon
I have that much pretty well working. It was when I went to the second form
is where I was having a problem.

I discovered that when I would drag a field to the form VS2005 would create
a navigator for me that I could type in a PatientID and click the button to
get the row of data.

I took part of the code it generated and modified it to plug in the
PatientID passed from the other form and it works fine now. I had to do that
for each table adapter of which there were about 12 to get all of the info
for that patient ID.

Here's one of the 12 lines of code to fetch the row of data:

this.pATIENTSTableAdapter.FillByPatientID(this.pat ients.PATIENTS,
Convert.ToInt32(this.Tag));

Thanks for your help.

Edwin
Feb 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.