Preview only show first 10 pages with watermark. For full document please download

Csharp Database Classes

   EMBED


Share

Transcript

C# Database Classes Connection CreateCommand() Open() Close() GetSchema() Command ExecuteReader() ExecuteScalar() ExecuteNonQuery() CommandText CommandType CommandTimeout DataReader HasRows Read() NextResult() GetValue(int) IsDbNull() DataTable DefaultView Load(DataReader) Rows Add(row) Find(value) Columns Add(name,type) Columns[“Last”] NewRow() TableName DataSet Select() Row Column DataView RowFilter DataSet Tables Add(DataTable) Tables[int] Creates a Command object that uses this connection Automatically executed by DataAdapter Fill() and Update() ditto Returns a DataTable of: “Tables”, “Views”, “Indexes”, “Procedures”, etc. Execute a query and return a DataReader (resultset) Execute a query and return a single value Execute a query like an ‘update’, ‘uinsert’ or ‘delete’. Returns # of rows affected Specifies the query (a string) commandtype.text (T-Sql) or commandtype.storedprocedure number of seconds Read next (or first) row Get the next resultset, if any Value of the ith column Is column value null Points to the DefaultView of the DataTable Load a resultset into a DataTable object A collection containing all the rows, you can iterate through Add (attach) a row object to a DataTable Find a row, using a particular value A collection of all the columns, you can iterate through Add a column to the DataTable Refers to a particular column by name Add a new row to the DataTable. Returns a Row Name of table Name of dataset Returns an array (collection) of rows A filter (string) you specify to limit rows available in the DataTable referred to Add a DataTable to the DataSet Points to a DataTable DataColumn Pointer to a column in a DataTable DataRelation 3 parms  Name of the data relation  Parent column  Child column DataAdapter new SqlDataAdapter(Command) new SqlDataAdapter(Query str, Connection str) Fill(DataTable) Subsequent execution merges new data into DataTable (i.e., updates or appends) Fill(DataSet) Update() SelectCommand UpdateCommand Auto created by the CommandBuilder, based on the SelectCommand InsertCommand ditto DeleteCommand ditto CommandBuilder  Is created referencing a DataAdapter  Creates default Update, Delete, and Create commands – based on a given Select command  Use a QuotePrefix and QuoteSuffix if table column names have spaces in them BindingSource DataSource DataTable, DataView, or BindingSource DataMember DataTable or DataRelation (if DataSource is a BindingSource) MoveNext() MovePrevious() MoveFirst() MoveLast() Count Number of rows (is affected by Filter()) Sort() Filter() Point to a subset of rows Find(col name, value) Search for a row with col = value. Sets the Position property. Position Get or set it to an integer value Current Pointer to a Row object, based on the value of Position EndEdit() Sends the edits in the bound object to the underlying DataTable Binding Used to bind a control, like a text box, to a data source 4 parms in constructor  Property name (string) “Text”  Data source (object)  Data member (string)  Fomat enabled (bool) DataGridView DataSource DataTable, DataView, BindingSource CurrentCell OwningColumn HeaderText CurrentRow Cells[int] ColumnCount Columns[int]