A class for beginners to define Databases

Source: Internet
Author: User

Today, there is nothing urgent to do. Just a few days ago, a netizen asked questions about Database Class settings. I hope he can understand the content, the most important thing about programming is to understand the memory by yourself. See more. Do more and ask more questions. This is an unbeaten option for me to learn ~~
The code for the data definition class is as follows:

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. Data. oledb;

/// <Summary>
/// Summary of the database
/// </Summary>
Public class DB
{
Public dB ()
{
//
// Todo: add the constructor logic here
//
}
// Database connection
Public static oledbconnection con ()
{
Oledbconnection con = new oledbconnection (configurationsettings. deleettings ["strcon"]);
Return con;
}
// Verify Logon
Public static bool insert (string que)
{
Oledbconnection con = dB. Con ();
Con. open ();
Oledbcommand cmd = new oledbcommand (que, con );
Int COUNT = convert. toint32 (CMD. executenonquery ());
If (count> 0)
{Return true ;}
Else
{Return false ;}

}
// Fill in data
Public static datatable DS (string que)
{
Oledbconnection con = dB. Con ();
Oledbdataadapter da = new oledbdataadapter ();
Da. selectcommand = new oledbcommand (que, con );
Dataset DS = new dataset ();
Da. Fill (DS, "4ec ");
Return Ds. Tables ["4ec"];
}
Public static string SCR (string que)
{
Oledbconnection con = dB. Con ();
Con. open ();
Oledbcommand cmd = new oledbcommand (que, con );
Return cmd. executescalar (). tostring ();

}

}
I have found many examples on the Internet. Are there any plagiarism? I hope you will not be surprised at this. This is an introduction for beginners ..............

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.