Database content in ASP.net

Source: Internet
Author: User
Adapter Fill Table
---------------------
Const C = 'data Source = LocalHost "MSSQL; Initial Catalog = pubs; User ID = sa; Password = admin ';
S = 'select * from employee ';

Procedure TmainForm. button#click (sender: System. Object; e: System. EventArgs );
Var Adapter: SqlDataAdapter;
Table: DataTable;
Begin
Table: = DataTable. Create;
Adapter: = SqlDataAdapter. Create (S, C );
Adapter. Fill (Table );
GridView1.DataSource: = Table;
GridView1.DataBind;
End;
---------------------
Adapter Fill Two Table in DataSet and Show
-----------------------------------------------
Const C = 'data Source = LocalHost "MSSQL; Initial Catalog = pubs; User ID = sa; Password = admin ';
S = 'select * from employee; select * from job'; // Use; to separator two Sentence

Procedure TmainForm. button#click (sender: System. Object; e: System. EventArgs );
Var Adapter: SqlDataAdapter;

TableSet: DataSet;
Begin

Adapter: = SqlDataAdapter. Create (S, C );
TableSet: = DataSet. Create;
Adapter. Fill (TableSet );
// --- Show First Table
GridView1.DataSource: = TableSet. Tables [0]. DefaultView;
GridView1.DataBind;
// -- Show Next Table
GridView2.DataSource: = TableSet. Tables [1]. DefaultView;
GridView2.DataBind;
End;
--------------------------------------------------------------
How to filter data in the GridView
---------------------------
Const c_cnn = 'data Source = LocalHost "MSSQL; Initial Catalog = Northwind; User ID = sa; Password = admin ';
C_sel = 'select * from MERs MERS; select * from employees; select * from suppliers ';
Var
SqlDA: SqlDataAdapter;
DS: DataSet;
Procedure TDefault. button#click (sender: System. Object; e: System. EventArgs );

Begin
SqlDA: = SqlDataAdapter. Create (c_sel, c_cnn );
DS: = DataSet. Create;
SqlDA. Fill (DS );
GridView1.DataSource: = DS;
GridView1.DataBind;
End;

Procedure TDefault. Button2_Click (sender: System. Object; e: System. EventArgs );
Begin
DS. Tables [0]. DefaultView. RowFilter: = TextBox1.Text;
GridView1.DataSource: = DS. Tables [0]. DefaultView; // You must Bind the data again here.
GridView1.DataBind;
End;

-----------------------------------
How to Create a relational table?
-----------------
Const c_cnn = 'data Source = LocalHost "MSSQL; Initial Catalog = Northwind; User ID = sa; Password = admin ';
C_sel = 'select * from suppliers; select * from products ';
Var
SqlDA: SqlDataAdapter;
DS: DataSet;

Procedure TDefault. Page_Load (sender: System. Object; e: System. EventArgs );
Begin
SqlDA: = SqlDataAdapter. Create (c_sel, c_cnn );
DS: = DataSet. Create;
SqlDA. Fill (DS );
End;

Procedure TDefault. OnInit (e: EventArgs );
Begin
//
// Required for Designer support
//
InitializeComponent;
Inherited OnInit (e );
End;

Procedure TDefault. button#click (sender: System. Object; e: System. EventArgs );
Begin
DS. Relations. Add ('supprod', DS. Tables [0]. Columns ['supplierid'], DS. Tables [1]. Columns ['supplierid']);
// Set the Link name.
GridView1.DataSource: = DS. Tables [0]. DefaultView;
GridView1.DataBind;
DS. Tables [1]. DefaultView. RowFilter: = DS. Tables [0]. Columns ['supplierid']. ToString + '= 1 ';
// Retrieve the content of the second table. dynamic conditions are not allowed ????
GridView2.DataSource: = DS. Tables [1]. DefaultView;
GridView2.DataBind;
End;
--------- How to read the database connection configuration in WEB. Config -------------------
Procedure TDefault. button#click (sender: System. Object; e: System. EventArgs );
Var
Configurationconfigurettings: System. Configuration. AppSettingsReader; // pay attention to this reference.
S: string;
Begin
Configurationconfigurettings: = System. Configuration. configurettingsreader. Create; // You must Create a Configuration service application.
S: = (string (configurationetettings. GetValue ('sqlconnection1. connectionstring', TypeOf (string ))));
Response. Write (s );
End;
--------------------------------------------------------------------
About Using frame (template file)
1. Project-> add-> Other-> ASP. netMaster Page
2. ContentPlaceHolder is a reserved region and is used by users,
3. Other regions are mandatory. You can place the things to be inherited in this range.
4, project-> add-> new-> Other-ASP.net Content Page-> write the Master Page name on the Master Page File
OK
------------------------------------

Http://design.yesky.com/homepage/414/2215914.shtml

-------------------------------------------------
Hypertext does not show underscores
----------------------
<Style type = "text/css">
<! -
A: link {text-decoration: none}
A: hover {text-decoration: none}
A: visited {text-decoration: none}
->
</Style>
-----------------------
Set hyperlink color
-------------
<Style>
<! --
A: link {color: # 0020FF; text-decoration: none; font-size: 9pt}
A: visited {color: # 0020FF; text-decoration: none; font-size: 9pt}
A: hover {color: red; text-decoration: none; font-size: 9pt}
-->
</Style>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.