Posts

Showing posts with the label ASP.Net and ADO.net

Joining Tables in database (inner join)

Joining tables:    Joins are a fundamental aspect of relation databases. They allow us to extract data on intites related by design represented by related tables in our data. A join occurs when you retrieve data from tables related by some shared data, often a shared reference number or index. Foe example, if you have a table of customers as a table of orders, good design in a relation database will ensure that the two are related together by some common data between the tables, perhaps by storing a customer number on every order record . By performing a join, you can retrieve information in a result set where each row combines data from both tables: information about each order will be combined with information about the customer who placed it, and the combination will appear as such in the result set.  INNER JOIN:     IT IS THE MOST COMMON TYPE OF JOIN. WHEN YOU PERFORM AS INNER JOIN BETWEEN tables, rows with matching values are put into the resu

Data types in database with description

Image
Data types     Mysql can handle the following data types:   Numeric values String values Data and time values The null values Numeric column types   The mysql can represent both integers (number with no fractional part) and floating point numbers (those with fractional part). Numeric column attributes    When declaring a numeric column not only can the column name and type be specified but also some column attributes. Column_ name column_ type [column _attributes] [genersl_arribute] Zero fill: it can be used with any numeric column type. Whenever displaying a value of a column with zero fill specified “the output will be padded with leading zero up to the display width of the column. Auto_ increment   We can use the auto_ increment attribute to generate a unique alto numbered identifier.   Mysql permits only one auto_ increment column per table and requires that it is also declared as a key. ‘By default an auto increment column will have it’s start

ASP.NET Validator Controls

ASP.NET Validator Controls   This tutorial gives a brief overview of how to use the ASP.NET Input Validation Controls. Back when we had only ASP, developers who had to write webpages for forms knew that the most tedious part is writing code to validate the user input. User input had to be validated so that malicious use of the pages couldn't be achieve. User input had to be validated so that an incorrect piece of information would not be entered. User input had to be validated so that the information stored was standardized. Yeah, some people had libraries of ASP functions to validate common things such as postal codes (zip codes for you Americans), e-mail addresses, phone numbers, etc. The developers of ASP.NET saw the tedium in always having to check user input. They decided that to simplify our life by including validation controls. ASP.NET validation controls also provide two ways of validation: Server-side or Clien

Retrieving Schema Information from the Data Source

Image
Retrieving Schema Information from the Data Source Schema information can be retrieved from a data source using the FillSchema( ) method, which retrieves the schema information for the SQL statement in the SelectCommand . The method adds a DataTable to the DataSet and adds DataColumn objects to that table. Finally, it configures the AllowDBNull , AutoIncrement , MaxLength , ReadOnly , and Unique properties of the DataColumn , based on the data source. While it configures the AutoIncrement property, it doesn't set the AutoIncrementSeed and AutoIncrementStep properties. The FillSchema( ) method also configures the primary key and unique constraints for the DataTable . It doesn't configure the DefaultValue property. In addition to an argument specifying the DataSet argument, the FillSchema( ) method takes an argument specifying whether the schema is transformed by the table mappings for the data adapter. Mapping tables and columns

Creating DataAdapter Object

Creating DataAdapter Object The overloaded constructor for the DataAdapter allows four different ways to create the data adapter, of which two are most commonly used. The following example creates a DataAdapter specifying the SELECT statement and connection string in the constructor. String connString = "Data Source=(local);Integrated security=SSPI;" +     "Initial Catalog=Northwind;"; String selectSql = "SELECT * FROM Orders";   SqlDataAdapter da = new SqlDataAdapter(selectSql, connString); While this approach is common, it is awkward when using parameterized queries or stored procedures. The following example creates a DataAdapter specifying a Command object for the SelectCommand property of the DataAdapter in the constructor: // create the Connection String connString = "Data Source = (local);Integrated security = SSPI;" +     "Initial Catalog = Northwind;"; SqlConnection conn = new SqlConn

AcceptChanges and RejectChanges

AcceptChanges and RejectChanges The AcceptChanges( ) and RejectChanges( ) methods either accept or reject the changes that have been made to the DataSet since it was last loaded from the data source or since AcceptChanges( ) was last called. The AcceptChanges( ) method commits all pending changes within the DataSet . Calling AcceptChanges( ) changes the RowState of Added and Modified rows to Unchanged . Deleted rows are removed. The Original values for the DataRow are set to the Current values. Calling the AcceptChanges( ) method has no effect on the data in the underlying data source. The AcceptChanges( ) method is implicitly called on a row when the DataAdapter successfully updates that row back to the data source when the Update( ) method is called. As a result, when a DataAdapter is used to update the data source with the changes made to the DataSet , AcceptChanges( ) doesn't need to be called. Calling AcceptChanges( ) o