how to specify which row is to be displayed?

E

Edwin Smith

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
 
M

mangist

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
 
E

Edwin Smith

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.patients.PATIENTS,
Convert.ToInt32(this.Tag));

Thanks for your help.

Edwin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top