Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Recently I posted a question how to get a record from a table from my main view in to another window for a "detail" view. The members of CodeProject were extremely helpful with this. I have attempted to do this again but without using a GUID this time as my key. I'm now using an int. I would've thought all I had to do was change the datatype of GUID in my constructor to int and that would be finished. My project is not receiving any errors but when I double click on a row of the table I get my exception message that I have no records selected.

Here is the code from my MainWindow.
C#
private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                System.Data.DataRowView selectedRowView;
                Logscan_RequestDataSet.LOGSCAN_REQUESTRow selectedRow;

                selectedRowView = (System.Data.DataRowView)this.lOGSCAN_REQUESTBindingSource.Current;

                selectedRow = (Logscan_RequestDataSet.LOGSCAN_REQUESTRow)selectedRowView.Row;

                EditRecord editRecordForm = new EditRecord(REQUEST_ID);
                editRecordForm.EditRecord_Selected(selectedRow.REQUEST_ID);
                editRecordForm.Show();
            }
            catch
            {

                MessageBox.Show("You have no record selected.");
            }

        }


       // public Guid GUID { get; set; }


        public int REQUEST_ID { get; set; }




Here is the code from my EditRecord window.

C#
public partial class EditRecord : Form
    {
        public int REQUEST_ID { get; set; }

        public EditRecord(int REQUEST_ID)
        {
            InitializeComponent();
  //         this.REQUEST_ID = REQUEST_ID;
            //this.LOGSCAN_RESQUESTTableAdapter.FillByGuid(this.cj96DataSet.cj96TBRisc, REQUEST_ID);
            this.lOGSCAN_REQUESTTableAdapter.FillByGUID(this.logscan_RequestDataSet.LOGSCAN_REQUEST, REQUEST_ID);
        }

        internal void EditRecord_Selected(int REQUEST_ID)
        {
            this.lOGSCAN_REQUESTTableAdapter.FillByGUID(this.logscan_RequestDataSet.LOGSCAN_REQUEST, REQUEST_ID);
        }
Posted
Comments
Pheonyx 14-Mar-14 12:19pm    
Just an observation, but have you changed your code in your table adapter, you are calling a "FillByGUID" method but are passing an int.
Branden Coker 14-Mar-14 12:27pm    
This is my FillMethod I just named it FillByGUID so I could keep it straight in my mind.

SELECT REQUEST_ID, AGENCY_NAME, ORI, ADDRESS, CITY, STATE, ZIPCODE, REQUEST_TITLE, REQUEST_LNAME, REQUEST_FNAME, PHONE_NUMBER,
EXTENSION, SUPERVISOR_LNAME, SUPERVISOR_FNAME, SUPERVISOR_PHONE, CELL_PHONE, FAX_NUMBER, REQUEST_REASON,
SEARCHTYPE, ADDWHEN, DELETEWHEN, DELETEBY, DELETE_IND, MODIFYWHEN, MODIFYBY, RESULT, CRITERIA, INDICATOR
FROM LOGSCAN_REQUEST
WHERE (REQUEST_ID = @REQUEST_ID)
Sergey Alexandrovich Kryukov 14-Mar-14 13:24pm    
Well, you have no records selected, so what? Always use the debugger to see what's going on. How is it all related to your question about constructors? Where is it? Which one?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900