简单的C#写入和读取数据库怎么实现?

图片说明
如图,就是想要实现简单的三个textbox文本框写入数据库和读取的功能。有木有大神帮忙做一下?

http://www.cnblogs.com/jxsoft/archive/2011/05/06/2038851.html

代码供参考
private void InsertPowerConsumption(string strMacAddr, float fPowerConsump)
{
SqlConnection sqlConn = new SqlConnection(connectionString);
try
{

            if (sqlConn.State != ConnectionState.Open)
            {
                sqlConn.Open();
            }

            //insert the power consumption data into the database

            string strLightID = getLightByMac(strMacAddr);

            string strPowConsump = fPowerConsump.ToString();
            string strTime = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss:fff");

            if (strLightID != "null")
            {
                string strSql = string.Format("insert into Power_Consumption(LIGHT_ID, CONSUMPTION, TIME,  PU_ID) values({0}, {1}, '{2}', 1)",
                                        strLightID,
                                        strPowConsump,
                                        strTime);

                SqlCommand sqlCommand = new SqlCommand(strSql);
                sqlCommand.Connection = sqlConn;
                if (sqlCommand.ExecuteNonQuery() != 1)
                {
                    throw (new Exception());
                }
                WriteLogEx(strSql);
            }

            if (sqlConn.State != ConnectionState.Closed)
            {
                sqlConn.Close();
            }
        }
        catch (Exception exp)
        {
            if (sqlConn.State != ConnectionState.Closed)
            {
                sqlConn.Close();
            }
            WriteLogEx(exp.Message);
        }
    }