asp.net access add an implementation method that returns a self-incrementing ID 1th/3 page _ Practical Tips

Source: Internet
Author: User
First look at the interface:


After adding the database:


And the statement to execute:
Copy Code code as follows:

String name_ = This.tbxUseName.Text.Trim ();
String webname_ = This.tbxWebName.Text.Trim ();
String url_ = This.tbxUrl.Text.Trim ();
Addfielditem ("News_title", name_);
Addfielditem ("News_source", webname_);
Addfielditem ("News_anthor", Url_);
Common.salert ("Add succeeded, add ID is" + insert ("Db_news"). ToString ());

When I read the small Confucius CMS to insert data processing, I feel. NET level has remained in the ASP. Here's a combination of code to talk about:
What needs to be explained is that the small Confucius CMS in the insertion of the use of multi-layer architecture, and this article is mainly focused on the study, so I did not get into multilayer. The insertion takes a parameterized process, a SQL-like stored procedure, and the insertion of data into the actual application is simple, as shown in the code above.

Let's first talk about a class [Dbkeyitem]:
Copy Code code as follows:

<summary>
Field properties in Datasheet: Field name, field value
</summary>
public class Dbkeyitem
{

<summary>
Field name
</summary>
public string FieldName;

<summary>
Field value
</summary>
public string Fieldvalue;

Public Dbkeyitem (String _fieldname, Object _fieldvalue)
{
This.fieldname = _fieldname;
This.fieldvalue = _fieldvalue.tostring ();
}
}

This class contains two properties:
1, fieldName: Field name
2, Fieldvalue: Field value

This class is used primarily for:
Copy Code code as follows:

protected ArrayList Alfielditems = new ArrayList (10);

<summary>
Add a field/value pair to the array
</summary>
public void Addfielditem (string _fieldname, Object _fieldvalue)
{
_fieldname = "[" + _fieldname + "]";
Traversal to see if the field name already exists
for (int i = 0; i < This.alFieldItems.Count; i++)
{
if (((Dbkeyitem) this.alfielditems[i]). FieldName = = _fieldname)
{
throw new ArgumentException ("Field already exists");
}
}
THIS.ALFIELDITEMS.ADD (New Dbkeyitem (_fieldname, _fieldvalue));
}

Current 1/3 page 123 Next read the full text

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.