If you want to write a stand-alone MIS, small web site, and so on the database performance requirements of the system, and do not want to install SQL Server, you can use Access (MDAC), as long as an MDB file.
Use Access to create an MDB file and build a table.
OleDbConnection, OleDbCommand ..., usage is about the same as SQL Server. and SQL Server are different:
Some complex SQL functions, syntax access is not supported.
The parameterized query does not use the @name placeholder, but instead uses the?, New OleDbParameter ("?", GUID. ToString () to add OleDbParameter in the order of the SQL statements.
Name and password are reserved words, preferably not used as column names, with the words added []
String str = configurationmanager.connectionstrings["ConnStr"]. ConnectionString; String pName = configurationmanager.connectionstrings["ConnStr"]. ProviderName; IDbConnection Conn; if (pName = = "SQL Server") { conn = new SqlConnection (str); } else if (PName = = "Access") { conn = new OleDbConnection (str); } else { MessageBox.Show ("Invalid providername! "); return; } using (conn) //polymorphism, no one knows whether Conn is SQL or access { if (conn). state = = connectionstate.closed) { Conn. Open (); } using (IDbCommand cmd = conn. CreateCommand ()) { cmd. CommandText = "Insert into T_person (name,age) Values ('" + txtName.Text + "'," + Convert.ToInt32 (txtage.text) + ")"; if (Convert.ToInt32 (cmd). ExecuteNonQuery ()) > 0) { MessageBox.Show ("added success!) "); } } }
Accessing an Access database (polymorphic when there are multiple databases)