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