CYQ Study Main Summary 2

Source: Internet
Author: User
Tags connectionstrings

The database configuration is assumed as follows:

<connectionStrings>
<add name= "Conn" connectionstring= "server=.; database=cqspace;uid=sa;pwd=123456 "/>
<add name= "Cyq" connectionstring= "server=.; database=cqspace;uid=sa;pwd=123456 "/>
</connectionStrings>

An instance method of the Action class:

Method One: The link string for the default fetching profile Conn

Maction action = new maction (tablenames.cq_blogset);

Method Two: Taken from a link string that defines a name such as CYQ:

Maction action = new Maction (Tablenames.cq_blogset, "Cyq");

Method Three: Direct fetch link string

Maction action = new Maction (Tablenames.cq_blogset, "server=.; database=cqspace;uid=sa;pwd=123456 ");

Let's take a look at what you can do to update:

1: Single data Query method:

Way one: Pass ID directly

Maction action = new maction (tablenames.cq_blogset);
if (action. Fill (888))
{
Action. Setto (Lblalbumtype);
Action. Close ();
}

Way two: pass Where condition

Maction action = new maction (tablenames.cq_blogset);
if (action. Fill ("title= ' xxxx ')")
{
Action. Setto (Lblalbumtype);
Action. Close ();
}

2: Data deletion:

Method One: First fill and then delete

if (action. Fill (888))
{
Action. Delete ();
Action. Close ();
}

Method Two: Delete by ID

Maction action = new maction (tablenames.cq_album);
Action. Delete (888);
Action. Close ();

Method Three: Delete according to the condition

Maction action = new maction (tablenames.cq_album);
Action. Delete ("id>888");
Action. Close ();

3: Data Update

Method One: Populate and update first

Maction action = new maction (tablenames.cq_album);
if (action. Fill (111))
{
Action. Getfrom (Txtalbumname);
Action. Update ();
Action. Close ();
}

Mode two: update based on ID

Maction action = new maction (tablenames.cq_album);
Action. Getfrom (Txtalbumname);
Action. Update (111);
Action. Close ();

Method Three: Update according to the condition

Maction action = new maction (tablenames.cq_album);
Action. Getfrom (Txtalbumname);
Action. Update ("id=299 or name= ' passing Autumn '");
Action. Close ();

4: Data list query and multi-table joint query did not change, and the same as the above.

See the first section: Cyq.data Light Data Layer Road opening introduction (i)

5: New Add count query:

Maction action = new maction (tablenames.cq_blogset);
Lblalbumtype.text = action. GetCount ("Id>2 and name= ' passing Autumn '"). ToString ();
Action. Close ();

6: To further hide the index value and assignment resulting from the Get and set method:

In the previous section of the upgrade, the newly added getfrom and Setto can only operate on the control assignment, if we just need to take a value, or set a value, there is no control in the middle?

Before the previous section, we can only go back to the index in the way of values such as:

String albumtype=action. Data[cq_album.albumname]. Value.tostring ();

After the mania upgrade: Using the new Get method to take the value, the effect becomes:

String albumtype = action. Get<string> (Cq_album.albumname);

The Set method is assigned the following values:

Action. Set (Cq_album.albumname, "passing Autumn";);

Therefore, for the value and assignment, we currently have 3 ways to use:

1: For the control type: Getfrom and Setto

2: For variable type: Get and set

3: Reserved: Index data/enumeration with field name (string) value

CYQ Study Main Summary 2

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.