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;
}