예제 #1
0
        public static SqlConnection GetDBConnection()
        {
            string datasource = @".\SQLEXPRESS";

            string database = "test";
            string username = "******";
            string password = "******";

            return(DBSQLServerUtils.GetDBConnection(datasource, database, username, password));
        }
예제 #2
0
        public static bool StoreDht11(double temp, double humi)
        {
            try
            {
                SqlConnection conn = DBSQLServerUtils.GetDBConnection();
                SqlCommand    cmd  = new SqlCommand("insert into dht11_data (temp,humi) values (@temp,@humi)", conn);
                cmd.Parameters.AddWithValue("@temp", temp);
                cmd.Parameters.AddWithValue("@humi", humi);
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }