This class is a database operation class that we often use when doing projects. It is very practical. Let's take a look...
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. SqlClient;
/** // <Summary>
/// Summary of BaseClass
/// </Summary>
Public class BaseClass
...{
Public BaseClass ()
...{
//
// TODO: add the constructor logic here
//
}
// This method is used to insert, modify, and delete SQL statements. If the return value is Boolean, True is returned. If the return value is True, False is returned.
Public Boolean ExecSQL (string SQueryString)
...{
SqlConnection con = db. ceratcon ();
Con. Open ();
SqlCommand cmd = new SqlCommand (SQueryString, con );
Try
...{
Cmd. ExecuteNonQuery ();
Con. Close ();
}
Catch
...{
Con. Close ();
Return false;
}
Return true;
}
Public void ExecSQL ()
...{
Throw new Exception ("The method or operation is not implemented .");
}
}
BaseClass bc = new BaseClass (); // call the database operation class
MessageBox msg = new MessageBox ();
Protected void Page_Load (object sender, EventArgs e)
...{
}
Protected void button#click (object sender, EventArgs e)
...{
Bc. ExecSQL ("insert into TestNews (Nname) values ('" + this. TextBox1.Text + "')");
Response. Write (msg. Message ("added successfully! "));
}
}