type 1:
Conn. open ();
sqlcommand cmd = new sqlcommand (" addnews ", Conn);
cmd. commandtype = commandtype. storedprocedure;
cmd. parameters. add (New sqlparameter ("@ ID", sqldbtype. int, 4);
cmd. parameters. add (New sqlparameter ("@ title", sqldbtype. nvarchar, 200);
cmd. parameters. add (New sqlparameter ("@ content", sqldbtype. nvarchar, 4000);
cmd. parameters. add (New sqlparameter ("@ publishtime", sqldbtype. datetime, 8);
cmd. parameters. add (New sqlparameter ("@ replies", sqldbtype. int, 4);
cmd. updatedrowsource = updaterowsource. none;
Cmd. Parameters ["@ ID"]. value = art. ID;
Cmd. Parameters ["@ title"]. value = art. title;
Cmd. Parameters ["@ content"]. value = art. content;
Cmd. Parameters ["@ publishtime"]. value = art. publishtime;
Cmd. Parameters ["@ replies"]. value = art. replies;
Cmd. executenonquery ();
Conn. Close ();
Second:
Private bool borrowreader (string readerid)
{
If (readerborrowednumber (readerid) <8)
{
Sqlcommand borrowbook = new sqlcommand ();
Borrowbook. Connection = This. sqlconnection1;
Borrowbook. commandtype = commandtype. storedprocedure;
Borrowbook. commandtext = "DBO. storedprocedureborrowreader ";
Sqlparameter parinput =Borrowbook. Parameters. Add ("@ readerid", sqldbtype. Char );
Parinput. Direction = parameterdirection. input;
Parinput. value = readerid;
Try
{
This. sqlconnection1.open ();
Borrowbook. executenonquery ();
This. sqlconnection1.close ();
Return true;
}
Catch (system. Exception E)
{
This. errorhandle (E );
This. sqlconnection1.close ();
Return false;
}
}
Else
Return false;
}
In the above two methods, the color is combined to better understand and write.