C # operations TreeView, Database read data (2017-12-12 learning Note)

Source: Internet
Author: User

1. Learn the points of knowledge:

Database operation Syntax:

SqlConnection Database Connection Object

SqlConnection con =new SqlConnection ();

Con.open ();//Open database

SqlCommand Database Operations Command

SQlCommand com =new SQlCommand ();

com.commandtype=com.commandtext;//operation type is a database SQL statement

com.commandtext= "SELECT * from TB";//SQL statement executed

Com. Parameters.Add ("@id", SqlDbType.Int);//define an input parameter @id the search value for the SQL statement such as: SELECT * from TB where [email protected] SqlDbType. Int defines the field type

Com. ExecuteReader ();//Execute DATABASE statement.

Sqldataadapater//To populate the dataset and update the database commands

Sqldataadapater adapater =new sqldataadapater ("SELECT * from TB", con);//Execute DATABASE statement, return a stream

DataSet _ds=new DataSet ();

Adapater. Fill (_ds);//Data fills into a dataset or

Adapater=com. ExecuteReader ();

Whlie (Adapater. Read ())//Adapater. Read () indicates that the forward view record is equivalent to _ds. Table[0]. rows[i]["id"].tostring ()

{

}

Adapater. Dispose ();//Release resources

Con. Close ();//Closing database connection

TreeView Knowledge Point

TreeNode tr=new TreeNode ("all");//define a tree node

Tr. Nodes.Add ("Level Two Node");

Tr. Nodes[index]. Nodes.Add ("")//index the location of the Add node

Treeview. The Checkboxs=true;//property check box displays

Treeview. imagelist=imagelist1;//Add picture Display imagelist1 is a picture control on the toolbar

Treeview. Expanall ();//Expand All nodes

C # operations TreeView, Database read data (2017-12-12 learning Note)

Related Article

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.