Specific code below
The namespace book information management
{
The class datacon
{
Private string MySqlCon="server=localhost; User id=root; The database=books management system management system; Persistsecurityinfo=True; Allowuservariables=True ";//this part I will introduce how to fill in the below;
Public DataTable ExecuteQuery (string sqlStr)//used to query; Is the equivalent of function can provide a reference, then write a SQL statement, in the string, to the function, can automatically perform,
{
SqlConnection con=new SqlConnection (@ MySqlCon);
Con. The Open ();
SqlCommand CMD=new SqlCommand ();
CMD. Connection=con;
Cmd.Com mandType=CommandType. Text;
Cmd.Com mandText=sqlStr;
DataTable dt=new DataTable();
SqlDataAdapter msda;
Msda=new SqlDataAdapter (CMD);
Msda. The Fill (dt);
Con. The Close ();
Return dt.
}
Public int ExecuteUpdate (string sqlStr)//used to increase deletion;
{
SqlConnection con=new SqlConnection (@ MySqlCon);
Con. The Open ();
SqlCommand CMD=new SqlCommand ();
CMD. Connection=con;
Cmd.Com mandType=CommandType. Text;
Cmd.Com mandText=sqlStr;
Int iud=0;
An iud=CMD. ExecuteNonQuery ();
Con. The Close ();
Return an iud.
}
}
}
CodePudding user response:
The allowuservariables=True to delete?CodePudding user response:
This is a Java, brother is in the wrong doorCodePudding user response:
The