Ado. NET additions and deletions check and change small summary

Source: Internet
Author: User
Tags bind

Three routines-----Additions, deletions, changes

Code

1 using System.Data.SqlClient;

2

3 SqlConnection conn = new SqlConnection ("xxx");

4

5

6 String sql = "XXX";

7

8 SqlCommand comm = new SqlCommand (SQL, conn);

9

Ten Conn. Open ();

11

Comm. ExecuteNonQuery ();

13

Conn. Close ();

Three routines-----Check (bind to DataGridView

Code

1 using System.Data.SqlClient;

2

3 SqlConnection conn = new SqlConnection ("xxx");

4

5 String sql = "XXX";

6

7 SqlDataAdapter da = new SqlDataAdapter (SQL, conn);

8

9 DataSet ds = new DataSet ();

10

One da. Fill (DS);

12

Datagridview1.datasource = ds. Tables[0];

14

15//To update the query statement to query the primary key columns

16

SqlCommandBuilder sd = new SqlCommandBuilder (DA);

18

Da. Update (ds. Tables[0]);

Three routines----check (bind to ListView)

Code

Using System.Data.SqlClient;

SqlConnection conn = new SqlConnection ("xxx");

String sql = "XX";

SqlCommand comm = new SqlCommand (SQL, conn);

Conn. Open ();

SqlDataReader Read = Comm. ExecuteReader ();

while (read. Read ())

{

ListViewItem LVI = new ListViewItem (read["xxx"). ToString ());

Lvi. Tag = read["id"];

LISTVIEW1.ITEMS.ADD (LVI);

Lvi. Subitems.addrange (new string[] {read["xxx"]. ToString ()});

}

Read. Close ();

Conn. Close ();

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.