Database operations using nbearlite

Source: Internet
Author: User
Tags connection reset connectionstrings
First, create a database instance. The parameter is the name of the connection string in connectionstrings.

<Connectionstrings>
<Add name = "maindb" connectionstring = "database = oa_new_test; server = .;
Uid = sa; Pwd = app1234; enlist = false;
Pooling = true; Connection Reset = false;
Trusted_connection = no; Connect timeout = 3000 ;"
Providername = "system. Data. sqlclient"/>

<Connectionstrings>

Protected nbearlite. Database DB = new nbearlite. Database ("maindb ");

 

New

Public void insert (wupin_apply_detail WP)
{
Insertsqlsection ISS = dB. insert (beyondbit. OA. dataaccess. Tables. wupin_apply_detail );

ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wa_id, WP. wa_id );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_id, WP. wp_apply_id );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_name, WP. wp_apply_name );
If (WP. wp_apply_time! = Datetime. maxvalue)
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_time, WP. wp_apply_time );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_uid, WP. wp_apply_uid );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_name, WP. wp_name );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_quantity, WP. wp_quantity );

Int I = iss. executereturnautoincrementid (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.id );
WP. ID = I;
}

Modify:

Public int Update (wupin_apply_detail WP)
{
Updatesqlsection ISS = dB. Update (beyondbit. OA. dataaccess. Tables. wupin_apply_detail );

ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wa_id, WP. wa_id );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_id, WP. wp_apply_id );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_name, WP. wp_apply_name );
If (WP. wp_apply_time! = Datetime. maxvalue)
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_time, WP. wp_apply_time );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_apply_uid, WP. wp_apply_uid );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_name, WP. wp_name );
ISS = iss. AddColumn (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.wp_quantity, WP. wp_quantity );
ISS = iss. Where (beyondbit. OA. dataaccess. Tables. wupin_apply_detail.id = 1 );

Int I = iss. Execute ();
Return I;
}
Query object:
Public wupin_apply_detail getentity (int id)
{
Idatareader DR = dB. Select (beyondbit. OA. dataaccess. Tables. wupin_apply_detail). Where (beyondbit. OA. dataaccess. Tables. region = ID). todatareader ();
Return parseentity (DR );
}

Public wupin_apply_detail parseentity (idatareader Dr)
{
Wupin_apply_detail entity = NULL;
If (dr. Read ())
{
Entity = new wupin_apply_detail ();

If (Dr ["ID"]! = NULL)
Entity. ID = convert. toint32 (Dr ["ID"]);
If (Dr ["wp_name"]! = NULL)
Entity. wp_name = convert. tostring (Dr ["wp_name"]);
If (Dr ["wp_quantity"]! = NULL)
Entity. wp_quantity = convert. toint32 (Dr ["wp_quantity"]);
If (Dr ["wp_apply_id"]! = NULL)
Entity. wp_apply_id = convert. toint32 (Dr ["wp_apply_id"]);
If (Dr ["wp_apply_uid"]! = NULL)
Entity. wp_apply_uid = convert. tostring (Dr ["wp_apply_uid"]);
If (Dr ["wp_apply_name"]! = NULL)
Entity. wp_apply_name = convert. tostring (Dr ["wp_apply_name"]);
If (Dr ["wp_apply_time"]! = NULL)
Entity. wp_apply_time = convert. todatetime (Dr ["wp_apply_time"]);
If (Dr ["wa_id"]! = NULL)
Entity. wa_id = convert. toint32 (Dr ["wa_id"]);
Dr. Close ();
}

Return entity;
}

 

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.