/// <summary> /// Releases this System.Windows.Forms.DataGrid. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { if (this.sqlDataAdapter != null) { this.sqlDataAdapter = null; } } base.Dispose(disposing); }
/// <summary> /// Load or reloads a subset of the table content. In order to successfully /// call this method, you need to call first the Initialize method. /// </summary> /// <param name="startRecord">The zero-based record number to start with.</param> /// <param name="maxRecords">The maximum number of records to retrieve.</param> public void RefreshData(int startRecord, int maxRecords) { if (this.LastKnownConnectionType == OlymarsDemo.DataClasses.ConnectionType.None) { throw new InvalidOperationException("You must call the 'Initialize' method before calling this method."); } switch (this.LastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: this.sqlDataAdapter = new OlymarsDemo.SqlDataAdapters.SqlDataAdapter_tblCustomer(this.connectionString, "tblCustomer"); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: this.sqlDataAdapter = new OlymarsDemo.SqlDataAdapters.SqlDataAdapter_tblCustomer(this.sqlConnection, "tblCustomer"); break; } this.dataSet = null; if (startRecord == -1 && maxRecords == -1) { this.sqlDataAdapter.FillDataSet(ref this.dataSet); } else { this.sqlDataAdapter.FillDataSet(ref this.dataSet, startRecord, maxRecords); } this.dataSet.Tables["tblCustomer"].Columns["Cus_LngID"].Caption = "Cus_LngID (update this label in the \"Olymars/ColumnLabel\" extended property of the \"Cus_LngID\" column)"; this.dataSet.Tables["tblCustomer"].Columns["Cus_StrLastName"].Caption = "Surname"; this.dataSet.Tables["tblCustomer"].Columns["Cus_StrFirstName"].Caption = "Cus_StrFirstName (update this label in the \"Olymars/ColumnLabel\" extended property of the \"Cus_StrFirstName\" column)"; this.dataSet.Tables["tblCustomer"].Columns["Cus_StrEmail"].Caption = "Cus_StrEmail (update this label in the \"Olymars/ColumnLabel\" extended property of the \"Cus_StrEmail\" column)"; this.bindingInProgress = true; this.DataSource = this.dataSet.Tables["tblCustomer"].DefaultView; this.bindingInProgress = false; }