For what purposes in the Object Sender, Eventargs
using system;
Using System.Collections.Genic;
Using System.comPonentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
using system.threading.tasks;
using System.Windows.Forms;
using system.data.sqlclient;
Namespace CBS.ADO_NET.TableConstraints.
{
Public Partial Class Form1: Form
{
Public Form1 ()
{
Initializecomponent ();
}
Private Void Form1_Load (Object Sender, Eventargs E)
{
String ConnectionString = @ "data source =. \ sqlexpress; initial catalog = shopdb; Integrated Security = True;"; // Creating a connection string
Dataset ds = new dataset ();
DataTable Customers = New Datatable ("Customers");
Datatable Orders = New Datatable ("Orders");
Using (SQLConnection Connection = New Sqlconnection (ConnectionString))
{
Connection.open ();
SQLommand Customerscmd = New Sqlcommand ("Select Customerno, Lname, Fname, Address1, Phone From Customers", Connection);
SQLommand Orderscmd = New Sqlcommand ("Select Order), Customerno, OrderDate From Orders", Connection);
SqldataReader OrdersReader = Orderscmd.executeReader (); // Get a DataReader for the OrderDetails table
// LoadWithSchema method allows you to create a DataTable object based on the DataReader object
// With the restrictions for columns as in the database and fill this table data
Orders.LoadWithschema (OrdersReader);
Ordersreader.Close ();
SQLDATAREADER CUSTOMERSRADER = Customerscmd.executeReader ();
Customers.LoadWithschema (CustomersReader);
CustomersReader.Close ();
}
// The DataReader object does not have information about the limitations of Datatable objects, such as
// UniqueConstraint, ForeignKeyConstraint and PrimaryKey, so you will have to create them manually
customers.primaryKey = new datacolumn [] {customers.columns [0]};
ds.Tables.Addrange (New Datatable [] {Customers, Orders});
// Creating ForeignKeyConstraint Restriction for OrderDetails table
var fk_customersorders = new foreignkeyconstraint (customers.columns ["Customerno"], orders.columns ["Customerno"]);
Orders.constraints.add (fk_customersorders);
parentgridview.datasource = customers; // Linking the ParentGridView controls element with table Products
childdatagridview.datasource = orders; // Binding the ChilddatagRidView controls with the OrderDetails table
}
}
}
using system;
Using System.Collections.Genic;
Using System.Linq;
using system.threading.tasks;
using System.Windows.Forms;
Namespace CBS.ADO_NET.TableConstraints.
{
Static Class Program
{
/// & LT; Summary & GT;
/// The Main Entry Point for the Application.
/// & LT; / Summary & GT;
[Stathed]
Static Void Main ()
{
Application.enablevisualstyles ();
Application.SetCompatibleTextRenderingDefault (False);
Application.Run (New Form1 ());
}
}
}
using system;
Using System.Collections.Genic;
Using System.Linq;
Using System.Text;
using system.threading.tasks;
using system.data.sqlclient;
Using System.Data;
Namespace CBS.ADO_NET.TableConstraints.
{
Static Class TBaleExtensoinclass.
{
// This method writes data to a table based on DataReader
Public Static Void Loadwithschema (This Datatable Table, SqldataReader Reader)
{
table.createschemaFromReader (Reader);
Table.load (Reader); // Load Method is used to download the DataTable rows from the data source in the DataTable table.
}
// This method creates restrictions on columns table based on the resulting DataReader object.
Private Static Void CreateschemaFromReader (This Datatable Table, SqldataReader Reader)
{
DataTable Schematable = Reader.getSchematable (); // Method Returns the table Describing the SQLDATAREADER object column metadata.
Foreach (Datarow SchemaRow in Schematable.Rows)
{
DataColumn Column = New DataColumn ((String) SchemaRow ["columnname"]); // Creating a column with a column name in the data source
column.allowdbnull = (bool) SchemaRow ["AllowDBNULL"]; // Obtaining the value of the property AllowDBNULL
column.datatype = (type) SCHEMAROW ["DATATYPE"]; // Get the value of the Datatype property
column.unique = (BOOL) SCHEMAROW ["ISUNIQUE"]; // Get the value of the Unique Properties
column.Readonly = (BOOL) SCHEMAROW ["ISReadOnly"]; // Obtaining the value of the Readonly Properties
column.autoincrement = (BOOL) SCHEMAROW ["ISIIDENTIY"]; // Receive the value of the AutoInCrement property
if (column.datatype == typeof (string)) // If the String type field
column.maxlength = (int) SchemaRow ["columnsize"]; // Get the value of the MaxLength property
if (column.autoincrement == true) // if the field with auto-accord
{column.autoincrementstep = -1; column.autoincrementseed = 0; } // Set AutoIncrementStep and AutoIncrementSeed properties
table.columns.add (column); // Add Created Column to Columns Collection Tables
}
}
}
}
Answer 1, Authority 100%
This is the so-called event handlers
form1_load (Object Sender, Eventargs E)
Sender
is the so-called call context, or an object that caused this event.
E
are used to transmit parameters to call the method.
Eventargs – Basic class for classes with data on events.
You can also see here